0s autopkgtest [17:23:39]: starting date and time: 2025-05-06 17:23:39+0000 0s autopkgtest [17:23:39]: git checkout: 9986aa8c Merge branch 'skia/fix_network_interface' into 'ubuntu/production' 0s autopkgtest [17:23:39]: host juju-7f2275-prod-proposed-migration-environment-9; command line: /home/ubuntu/autopkgtest/runner/autopkgtest --output-dir /tmp/autopkgtest-work.oa30iak_/out --timeout-copy=6000 --setup-commands 'ln -s /dev/null /etc/systemd/system/bluetooth.service; printf "http_proxy=http://squid.internal:3128\nhttps_proxy=http://squid.internal:3128\nno_proxy=127.0.0.1,127.0.1.1,localhost,localdomain,internal,login.ubuntu.com,archive.ubuntu.com,ports.ubuntu.com,security.ubuntu.com,ddebs.ubuntu.com,changelogs.ubuntu.com,keyserver.ubuntu.com,launchpadlibrarian.net,launchpadcontent.net,launchpad.net,keystone.ps5.canonical.com,objectstorage.prodstack5.canonical.com,radosgw.ps5.canonical.com\n" >> /etc/environment' --apt-pocket=proposed=src:matplotlib --apt-upgrade pandas --timeout-short=300 --timeout-copy=40000 --timeout-test=40000 --timeout-build=40000 --env=ADT_TEST_TRIGGERS=matplotlib/3.10.1+dfsg1-3 -- lxd -r lxd-armhf-10.145.243.254 lxd-armhf-10.145.243.254:autopkgtest/ubuntu/questing/armhf 19s autopkgtest [17:23:58]: testbed dpkg architecture: armhf 21s autopkgtest [17:24:00]: testbed apt version: 3.0.0 25s autopkgtest [17:24:04]: @@@@@@@@@@@@@@@@@@@@ test bed setup 26s autopkgtest [17:24:05]: testbed release detected to be: None 33s autopkgtest [17:24:12]: updating testbed package index (apt update) 35s Get:1 http://ftpmaster.internal/ubuntu questing-proposed InRelease [110 kB] 36s Get:2 http://ftpmaster.internal/ubuntu questing InRelease [110 kB] 36s Get:3 http://ftpmaster.internal/ubuntu questing-updates InRelease [110 kB] 36s Get:4 http://ftpmaster.internal/ubuntu questing-security InRelease [110 kB] 36s Get:5 http://ftpmaster.internal/ubuntu questing-proposed/main Sources [67.8 kB] 36s Get:6 http://ftpmaster.internal/ubuntu questing-proposed/multiverse Sources [27.3 kB] 36s Get:7 http://ftpmaster.internal/ubuntu questing-proposed/universe Sources [580 kB] 36s Get:8 http://ftpmaster.internal/ubuntu questing-proposed/main armhf Packages [125 kB] 36s Get:9 http://ftpmaster.internal/ubuntu questing-proposed/universe armhf Packages [603 kB] 36s Get:10 http://ftpmaster.internal/ubuntu questing-proposed/multiverse armhf Packages [14.8 kB] 36s Get:11 http://ftpmaster.internal/ubuntu questing/multiverse Sources [308 kB] 36s Get:12 http://ftpmaster.internal/ubuntu questing/universe Sources [21.3 MB] 37s Get:13 http://ftpmaster.internal/ubuntu questing/main Sources [1384 kB] 37s Get:14 http://ftpmaster.internal/ubuntu questing/main armhf Packages [1358 kB] 37s Get:15 http://ftpmaster.internal/ubuntu questing/universe armhf Packages [15.4 MB] 37s Get:16 http://ftpmaster.internal/ubuntu questing/multiverse armhf Packages [182 kB] 41s Fetched 41.7 MB in 5s (7667 kB/s) 42s Reading package lists... 48s autopkgtest [17:24:27]: upgrading testbed (apt dist-upgrade and autopurge) 49s Reading package lists... 50s Building dependency tree... 50s Reading state information... 50s Calculating upgrade...Starting pkgProblemResolver with broken count: 0 51s Starting 2 pkgProblemResolver with broken count: 0 51s Done 52s Entering ResolveByKeep 53s 53s Calculating upgrade... 55s The following packages will be upgraded: 55s base-files base-passwd btrfs-progs cloud-init cloud-init-base debianutils 55s dhcpcd-base diffutils dirmngr distro-info-data dpkg dpkg-dev ed ethtool 55s fwupd gcc-15-base gettext-base gir1.2-glib-2.0 gnupg gnupg-l10n gnupg-utils 55s gpg gpg-agent gpg-wks-client gpgconf gpgsm gpgv groff-base htop iso-codes 55s keyboxd less libatomic1 libbpf1 libdpkg-perl libelf1t64 libevdev2 libftdi1-2 55s libfwupd3 libgcc-s1 libglib2.0-0t64 libglib2.0-data libgpg-error-l10n 55s libgpg-error0 libjcat1 libmbim-glib4 libmbim-proxy libmm-glib0 libnftnl11 55s libnghttp2-14 libnpth0t64 libnuma1 libnvme1t64 libperl5.40 libqmi-glib5 55s libqmi-proxy libselinux1 libsemanage-common libsemanage2 libsensors-config 55s libsensors5 libsepol2 libstdc++6 libunistring5 liburcu8t64 libusb-1.0-0 55s libx11-6 libx11-data libxml2 lto-disabled-list man-db motd-news-config nano 55s netbase netcat-openbsd numactl openssh-client openssh-server 55s openssh-sftp-server patch perl perl-base perl-modules-5.40 publicsuffix 55s python3-attr python3-dbus python3-lazr.restfulclient python3-more-itertools 55s python3-packaging python3-s3transfer python3-wadllib sensible-utils sos 55s ubuntu-pro-client ubuntu-pro-client-l10n usb.ids usbutils 55s 97 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 55s Need to get 35.1 MB of archives. 55s After this operation, 668 kB disk space will be freed. 55s Get:1 http://ftpmaster.internal/ubuntu questing/main armhf motd-news-config all 13.7ubuntu1 [5260 B] 55s Get:2 http://ftpmaster.internal/ubuntu questing/main armhf base-files armhf 13.7ubuntu1 [75.4 kB] 55s Get:3 http://ftpmaster.internal/ubuntu questing/main armhf debianutils armhf 5.22 [92.2 kB] 55s Get:4 http://ftpmaster.internal/ubuntu questing/main armhf diffutils armhf 1:3.10-4 [172 kB] 55s Get:5 http://ftpmaster.internal/ubuntu questing/main armhf dpkg armhf 1.22.18ubuntu3 [1254 kB] 55s Get:6 http://ftpmaster.internal/ubuntu questing/main armhf libperl5.40 armhf 5.40.1-3 [4144 kB] 55s Get:7 http://ftpmaster.internal/ubuntu questing/main armhf perl armhf 5.40.1-3 [262 kB] 55s Get:8 http://ftpmaster.internal/ubuntu questing/main armhf perl-base armhf 5.40.1-3 [1667 kB] 55s Get:9 http://ftpmaster.internal/ubuntu questing/main armhf perl-modules-5.40 all 5.40.1-3 [3217 kB] 55s Get:10 http://ftpmaster.internal/ubuntu questing/main armhf libselinux1 armhf 3.8.1-1 [80.4 kB] 55s Get:11 http://ftpmaster.internal/ubuntu questing/main armhf base-passwd armhf 3.6.7 [53.9 kB] 55s Get:12 http://ftpmaster.internal/ubuntu questing/main armhf openssh-sftp-server armhf 1:9.9p1-3ubuntu3.1 [35.7 kB] 55s Get:13 http://ftpmaster.internal/ubuntu questing/main armhf openssh-server armhf 1:9.9p1-3ubuntu3.1 [532 kB] 55s Get:14 http://ftpmaster.internal/ubuntu questing/main armhf openssh-client armhf 1:9.9p1-3ubuntu3.1 [924 kB] 56s Get:15 http://ftpmaster.internal/ubuntu questing/main armhf libatomic1 armhf 15.1.0-2ubuntu1 [7966 B] 56s Get:16 http://ftpmaster.internal/ubuntu questing/main armhf gcc-15-base armhf 15.1.0-2ubuntu1 [54.6 kB] 56s Get:17 http://ftpmaster.internal/ubuntu questing/main armhf libgcc-s1 armhf 15.1.0-2ubuntu1 [40.6 kB] 56s Get:18 http://ftpmaster.internal/ubuntu questing/main armhf libstdc++6 armhf 15.1.0-2ubuntu1 [731 kB] 56s Get:19 http://ftpmaster.internal/ubuntu questing/main armhf libsemanage-common all 3.8.1-1 [7826 B] 56s Get:20 http://ftpmaster.internal/ubuntu questing/main armhf libsepol2 armhf 3.8.1-1 [282 kB] 56s Get:21 http://ftpmaster.internal/ubuntu questing/main armhf libsemanage2 armhf 3.8.1-1 [88.2 kB] 56s Get:22 http://ftpmaster.internal/ubuntu questing/main armhf libgpg-error-l10n all 1.51-4 [8880 B] 56s Get:23 http://ftpmaster.internal/ubuntu questing/main armhf libgpg-error0 armhf 1.51-4 [64.6 kB] 56s Get:24 http://ftpmaster.internal/ubuntu questing/main armhf libnpth0t64 armhf 1.8-3 [7716 B] 56s Get:25 http://ftpmaster.internal/ubuntu questing/main armhf gpg-wks-client armhf 2.4.4-2ubuntu24 [87.5 kB] 56s Get:26 http://ftpmaster.internal/ubuntu questing/main armhf dirmngr armhf 2.4.4-2ubuntu24 [348 kB] 56s Get:27 http://ftpmaster.internal/ubuntu questing/main armhf gpgsm armhf 2.4.4-2ubuntu24 [242 kB] 56s Get:28 http://ftpmaster.internal/ubuntu questing/main armhf gnupg-utils armhf 2.4.4-2ubuntu24 [160 kB] 56s Get:29 http://ftpmaster.internal/ubuntu questing/main armhf gpg-agent armhf 2.4.4-2ubuntu24 [237 kB] 56s Get:30 http://ftpmaster.internal/ubuntu questing/main armhf gpg armhf 2.4.4-2ubuntu24 [525 kB] 56s Get:31 http://ftpmaster.internal/ubuntu questing/main armhf gpgconf armhf 2.4.4-2ubuntu24 [117 kB] 56s Get:32 http://ftpmaster.internal/ubuntu questing/main armhf gnupg all 2.4.4-2ubuntu24 [359 kB] 56s Get:33 http://ftpmaster.internal/ubuntu questing/main armhf keyboxd armhf 2.4.4-2ubuntu24 [112 kB] 56s Get:34 http://ftpmaster.internal/ubuntu questing/main armhf gpgv armhf 2.4.4-2ubuntu24 [225 kB] 56s Get:35 http://ftpmaster.internal/ubuntu questing/main armhf sensible-utils all 0.0.25 [25.0 kB] 56s Get:36 http://ftpmaster.internal/ubuntu questing/main armhf dhcpcd-base armhf 1:10.1.0-10 [189 kB] 56s Get:37 http://ftpmaster.internal/ubuntu questing/main armhf distro-info-data all 0.64 [6664 B] 56s Get:38 http://ftpmaster.internal/ubuntu questing/main armhf gir1.2-glib-2.0 armhf 2.84.1-2 [185 kB] 56s Get:39 http://ftpmaster.internal/ubuntu questing/main armhf libglib2.0-0t64 armhf 2.84.1-2 [1455 kB] 56s Get:40 http://ftpmaster.internal/ubuntu questing/main armhf iso-codes all 4.18.0-1 [3703 kB] 56s Get:41 http://ftpmaster.internal/ubuntu questing/main armhf less armhf 668-1 [158 kB] 56s Get:42 http://ftpmaster.internal/ubuntu questing/main armhf libelf1t64 armhf 0.193-1 [50.2 kB] 56s Get:43 http://ftpmaster.internal/ubuntu questing/main armhf libbpf1 armhf 1:1.5.0-3 [158 kB] 56s Get:44 http://ftpmaster.internal/ubuntu questing/main armhf libglib2.0-data all 2.84.1-2 [53.2 kB] 56s Get:45 http://ftpmaster.internal/ubuntu questing/main armhf libunistring5 armhf 1.3-2 [583 kB] 56s Get:46 http://ftpmaster.internal/ubuntu questing/main armhf libxml2 armhf 2.12.7+dfsg+really2.9.14-0.4ubuntu0.1 [599 kB] 56s Get:47 http://ftpmaster.internal/ubuntu questing/main armhf netbase all 6.5 [12.9 kB] 56s Get:48 http://ftpmaster.internal/ubuntu questing/main armhf netcat-openbsd armhf 1.229-1 [42.4 kB] 56s Get:49 http://ftpmaster.internal/ubuntu questing/main armhf python3-dbus armhf 1.4.0-1 [96.6 kB] 56s Get:50 http://ftpmaster.internal/ubuntu questing/main armhf ubuntu-pro-client-l10n armhf 35.1ubuntu0 [19.7 kB] 56s Get:51 http://ftpmaster.internal/ubuntu questing/main armhf ubuntu-pro-client armhf 35.1ubuntu0 [258 kB] 56s Get:52 http://ftpmaster.internal/ubuntu questing/main armhf ed armhf 1.21.1-1 [53.0 kB] 56s Get:53 http://ftpmaster.internal/ubuntu questing/main armhf ethtool armhf 1:6.14-2 [230 kB] 56s Get:54 http://ftpmaster.internal/ubuntu questing/main armhf gettext-base armhf 0.23.1-2 [43.5 kB] 56s Get:55 http://ftpmaster.internal/ubuntu questing/main armhf groff-base armhf 1.23.0-8 [942 kB] 56s Get:56 http://ftpmaster.internal/ubuntu questing/main armhf libevdev2 armhf 1.13.4+dfsg-1 [29.8 kB] 56s Get:57 http://ftpmaster.internal/ubuntu questing/main armhf libnftnl11 armhf 1.2.9-1 [53.3 kB] 56s Get:58 http://ftpmaster.internal/ubuntu questing/main armhf libnghttp2-14 armhf 1.64.0-1.1 [68.5 kB] 56s Get:59 http://ftpmaster.internal/ubuntu questing/main armhf libnuma1 armhf 2.0.19-1 [19.9 kB] 56s Get:60 http://ftpmaster.internal/ubuntu questing/main armhf libsensors-config all 1:3.6.2-2 [6756 B] 56s Get:61 http://ftpmaster.internal/ubuntu questing/main armhf libsensors5 armhf 1:3.6.2-2 [26.8 kB] 56s Get:62 http://ftpmaster.internal/ubuntu questing/main armhf liburcu8t64 armhf 0.15.2-2 [57.3 kB] 56s Get:63 http://ftpmaster.internal/ubuntu questing/main armhf libusb-1.0-0 armhf 2:1.0.28-1 [50.0 kB] 56s Get:64 http://ftpmaster.internal/ubuntu questing/main armhf libx11-data all 2:1.8.12-1 [116 kB] 56s Get:65 http://ftpmaster.internal/ubuntu questing/main armhf libx11-6 armhf 2:1.8.12-1 [586 kB] 56s Get:66 http://ftpmaster.internal/ubuntu questing/main armhf man-db armhf 2.13.1-1 [1341 kB] 56s Get:67 http://ftpmaster.internal/ubuntu questing/main armhf nano armhf 8.4-1 [278 kB] 56s Get:68 http://ftpmaster.internal/ubuntu questing/main armhf numactl armhf 2.0.19-1 [38.5 kB] 56s Get:69 http://ftpmaster.internal/ubuntu questing/main armhf publicsuffix all 20250328.1952-0.1 [135 kB] 56s Get:70 http://ftpmaster.internal/ubuntu questing/main armhf usb.ids all 2025.04.01-1 [223 kB] 56s Get:71 http://ftpmaster.internal/ubuntu questing/main armhf usbutils armhf 1:018-2 [77.4 kB] 56s Get:72 http://ftpmaster.internal/ubuntu questing/main armhf btrfs-progs armhf 6.14-1 [901 kB] 56s Get:73 http://ftpmaster.internal/ubuntu questing/main armhf cloud-init-base all 25.2~1g7a0265d3-0ubuntu1 [619 kB] 56s Get:74 http://ftpmaster.internal/ubuntu questing/main armhf dpkg-dev all 1.22.18ubuntu3 [1089 kB] 56s Get:75 http://ftpmaster.internal/ubuntu questing/main armhf libdpkg-perl all 1.22.18ubuntu3 [281 kB] 56s Get:76 http://ftpmaster.internal/ubuntu questing/main armhf patch armhf 2.8-1 [94.1 kB] 56s Get:77 http://ftpmaster.internal/ubuntu questing/main armhf lto-disabled-list all 58 [12.4 kB] 56s Get:78 http://ftpmaster.internal/ubuntu questing/main armhf libjcat1 armhf 0.2.3-1 [30.9 kB] 56s Get:79 http://ftpmaster.internal/ubuntu questing/main armhf fwupd armhf 2.0.8-3 [1414 kB] 56s Get:80 http://ftpmaster.internal/ubuntu questing/main armhf libfwupd3 armhf 2.0.8-3 [126 kB] 56s Get:81 http://ftpmaster.internal/ubuntu questing/main armhf libmbim-proxy armhf 1.32.0-1 [5888 B] 56s Get:82 http://ftpmaster.internal/ubuntu questing/main armhf libmbim-glib4 armhf 1.32.0-1 [218 kB] 57s Get:83 http://ftpmaster.internal/ubuntu questing/main armhf libmm-glib0 armhf 1.24.0-1 [223 kB] 57s Get:84 http://ftpmaster.internal/ubuntu questing/main armhf libqmi-proxy armhf 1.36.0-1 [5882 B] 57s Get:85 http://ftpmaster.internal/ubuntu questing/main armhf libqmi-glib5 armhf 1.36.0-1 [936 kB] 57s Get:86 http://ftpmaster.internal/ubuntu questing/main armhf gnupg-l10n all 2.4.4-2ubuntu24 [66.8 kB] 57s Get:87 http://ftpmaster.internal/ubuntu questing/main armhf htop armhf 3.4.1-4 [147 kB] 57s Get:88 http://ftpmaster.internal/ubuntu questing/main armhf libftdi1-2 armhf 1.5-10 [27.8 kB] 57s Get:89 http://ftpmaster.internal/ubuntu questing/main armhf libnvme1t64 armhf 1.13-2 [74.3 kB] 57s Get:90 http://ftpmaster.internal/ubuntu questing/main armhf python3-attr all 25.3.0-1 [50.9 kB] 57s Get:91 http://ftpmaster.internal/ubuntu questing/main armhf python3-wadllib all 2.0.0-3 [36.3 kB] 57s Get:92 http://ftpmaster.internal/ubuntu questing/main armhf python3-lazr.restfulclient all 0.14.6-3 [51.0 kB] 57s Get:93 http://ftpmaster.internal/ubuntu questing/main armhf python3-more-itertools all 10.7.0-1 [59.6 kB] 57s Get:94 http://ftpmaster.internal/ubuntu questing/main armhf python3-packaging all 25.0-1 [52.8 kB] 57s Get:95 http://ftpmaster.internal/ubuntu questing/main armhf python3-s3transfer all 0.11.4-1 [55.8 kB] 57s Get:96 http://ftpmaster.internal/ubuntu questing/main armhf sos all 4.9.1-1 [367 kB] 57s Get:97 http://ftpmaster.internal/ubuntu questing/main armhf cloud-init all 25.2~1g7a0265d3-0ubuntu1 [2106 B] 57s Preconfiguring packages ... 58s Fetched 35.1 MB in 2s (16.7 MB/s) 58s (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 ... 63953 files and directories currently installed.) 58s Preparing to unpack .../motd-news-config_13.7ubuntu1_all.deb ... 58s Unpacking motd-news-config (13.7ubuntu1) over (13.6ubuntu2) ... 58s Preparing to unpack .../base-files_13.7ubuntu1_armhf.deb ... 58s Unpacking base-files (13.7ubuntu1) over (13.6ubuntu2) ... 58s Setting up base-files (13.7ubuntu1) ... 58s Installing new version of config file /etc/issue ... 58s Installing new version of config file /etc/issue.net ... 58s Installing new version of config file /etc/lsb-release ... 59s motd-news.service is a disabled or a static unit not running, not starting it. 59s (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 ... 63953 files and directories currently installed.) 59s Preparing to unpack .../debianutils_5.22_armhf.deb ... 59s Unpacking debianutils (5.22) over (5.21) ... 59s Setting up debianutils (5.22) ... 59s (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 ... 63953 files and directories currently installed.) 59s Preparing to unpack .../diffutils_1%3a3.10-4_armhf.deb ... 59s Unpacking diffutils (1:3.10-4) over (1:3.10-3) ... 59s Setting up diffutils (1:3.10-4) ... 59s (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 ... 63953 files and directories currently installed.) 59s Preparing to unpack .../dpkg_1.22.18ubuntu3_armhf.deb ... 59s Unpacking dpkg (1.22.18ubuntu3) over (1.22.18ubuntu2) ... 60s Setting up dpkg (1.22.18ubuntu3) ... 60s (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 ... 63953 files and directories currently installed.) 60s Preparing to unpack .../libperl5.40_5.40.1-3_armhf.deb ... 60s Unpacking libperl5.40:armhf (5.40.1-3) over (5.40.1-2) ... 60s Preparing to unpack .../perl_5.40.1-3_armhf.deb ... 60s Unpacking perl (5.40.1-3) over (5.40.1-2) ... 61s Preparing to unpack .../perl-base_5.40.1-3_armhf.deb ... 62s Unpacking perl-base (5.40.1-3) over (5.40.1-2) ... 62s Setting up perl-base (5.40.1-3) ... 62s (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 ... 63953 files and directories currently installed.) 62s Preparing to unpack .../perl-modules-5.40_5.40.1-3_all.deb ... 62s Unpacking perl-modules-5.40 (5.40.1-3) over (5.40.1-2) ... 63s Preparing to unpack .../libselinux1_3.8.1-1_armhf.deb ... 63s Unpacking libselinux1:armhf (3.8.1-1) over (3.7-3ubuntu3) ... 63s Setting up libselinux1:armhf (3.8.1-1) ... 63s (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 ... 63953 files and directories currently installed.) 63s Preparing to unpack .../base-passwd_3.6.7_armhf.deb ... 63s Unpacking base-passwd (3.6.7) over (3.6.6) ... 63s Setting up base-passwd (3.6.7) ... 63s (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 ... 63953 files and directories currently installed.) 63s Preparing to unpack .../openssh-sftp-server_1%3a9.9p1-3ubuntu3.1_armhf.deb ... 63s Unpacking openssh-sftp-server (1:9.9p1-3ubuntu3.1) over (1:9.9p1-3ubuntu3) ... 63s Preparing to unpack .../openssh-server_1%3a9.9p1-3ubuntu3.1_armhf.deb ... 63s Unpacking openssh-server (1:9.9p1-3ubuntu3.1) over (1:9.9p1-3ubuntu3) ... 64s Preparing to unpack .../openssh-client_1%3a9.9p1-3ubuntu3.1_armhf.deb ... 64s Unpacking openssh-client (1:9.9p1-3ubuntu3.1) over (1:9.9p1-3ubuntu3) ... 64s Preparing to unpack .../libatomic1_15.1.0-2ubuntu1_armhf.deb ... 64s Unpacking libatomic1:armhf (15.1.0-2ubuntu1) over (15-20250404-0ubuntu1) ... 64s Preparing to unpack .../gcc-15-base_15.1.0-2ubuntu1_armhf.deb ... 64s Unpacking gcc-15-base:armhf (15.1.0-2ubuntu1) over (15-20250404-0ubuntu1) ... 64s Setting up gcc-15-base:armhf (15.1.0-2ubuntu1) ... 64s (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 ... 63953 files and directories currently installed.) 64s Preparing to unpack .../libgcc-s1_15.1.0-2ubuntu1_armhf.deb ... 64s Unpacking libgcc-s1:armhf (15.1.0-2ubuntu1) over (15-20250404-0ubuntu1) ... 64s Setting up libgcc-s1:armhf (15.1.0-2ubuntu1) ... 64s (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 ... 63953 files and directories currently installed.) 64s Preparing to unpack .../libstdc++6_15.1.0-2ubuntu1_armhf.deb ... 64s Unpacking libstdc++6:armhf (15.1.0-2ubuntu1) over (15-20250404-0ubuntu1) ... 64s Setting up libstdc++6:armhf (15.1.0-2ubuntu1) ... 64s (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 ... 63953 files and directories currently installed.) 64s Preparing to unpack .../libsemanage-common_3.8.1-1_all.deb ... 64s Unpacking libsemanage-common (3.8.1-1) over (3.7-2.1build1) ... 64s Setting up libsemanage-common (3.8.1-1) ... 64s (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 ... 63953 files and directories currently installed.) 64s Preparing to unpack .../libsepol2_3.8.1-1_armhf.deb ... 64s Unpacking libsepol2:armhf (3.8.1-1) over (3.7-1) ... 64s Setting up libsepol2:armhf (3.8.1-1) ... 64s (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 ... 63953 files and directories currently installed.) 64s Preparing to unpack .../libsemanage2_3.8.1-1_armhf.deb ... 64s Unpacking libsemanage2:armhf (3.8.1-1) over (3.7-2.1build1) ... 64s Setting up libsemanage2:armhf (3.8.1-1) ... 65s (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 63953 files and directories currently installed.) 65s Preparing to unpack .../libgpg-error-l10n_1.51-4_all.deb ... 65s Unpacking libgpg-error-l10n (1.51-4) over (1.51-3) ... 65s Preparing to unpack .../libgpg-error0_1.51-4_armhf.deb ... 65s Unpacking libgpg-error0:armhf (1.51-4) over (1.51-3) ... 65s Setting up libgpg-error0:armhf (1.51-4) ... 65s (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 63953 files and directories currently installed.) 65s Preparing to unpack .../libnpth0t64_1.8-3_armhf.deb ... 65s Unpacking libnpth0t64:armhf (1.8-3) over (1.8-2) ... 65s Setting up libnpth0t64:armhf (1.8-3) ... 65s (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 63953 files and directories currently installed.) 65s Preparing to unpack .../0-gpg-wks-client_2.4.4-2ubuntu24_armhf.deb ... 65s Unpacking gpg-wks-client (2.4.4-2ubuntu24) over (2.4.4-2ubuntu23) ... 65s Preparing to unpack .../1-dirmngr_2.4.4-2ubuntu24_armhf.deb ... 65s Unpacking dirmngr (2.4.4-2ubuntu24) over (2.4.4-2ubuntu23) ... 65s Preparing to unpack .../2-gpgsm_2.4.4-2ubuntu24_armhf.deb ... 65s Unpacking gpgsm (2.4.4-2ubuntu24) over (2.4.4-2ubuntu23) ... 65s Preparing to unpack .../3-gnupg-utils_2.4.4-2ubuntu24_armhf.deb ... 65s Unpacking gnupg-utils (2.4.4-2ubuntu24) over (2.4.4-2ubuntu23) ... 65s Preparing to unpack .../4-gpg-agent_2.4.4-2ubuntu24_armhf.deb ... 65s Unpacking gpg-agent (2.4.4-2ubuntu24) over (2.4.4-2ubuntu23) ... 65s Preparing to unpack .../5-gpg_2.4.4-2ubuntu24_armhf.deb ... 65s Unpacking gpg (2.4.4-2ubuntu24) over (2.4.4-2ubuntu23) ... 65s Preparing to unpack .../6-gpgconf_2.4.4-2ubuntu24_armhf.deb ... 65s Unpacking gpgconf (2.4.4-2ubuntu24) over (2.4.4-2ubuntu23) ... 65s Preparing to unpack .../7-gnupg_2.4.4-2ubuntu24_all.deb ... 65s Unpacking gnupg (2.4.4-2ubuntu24) over (2.4.4-2ubuntu23) ... 65s Preparing to unpack .../8-keyboxd_2.4.4-2ubuntu24_armhf.deb ... 65s Unpacking keyboxd (2.4.4-2ubuntu24) over (2.4.4-2ubuntu23) ... 66s Preparing to unpack .../9-gpgv_2.4.4-2ubuntu24_armhf.deb ... 66s Unpacking gpgv (2.4.4-2ubuntu24) over (2.4.4-2ubuntu23) ... 66s Setting up gpgv (2.4.4-2ubuntu24) ... 66s (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 63953 files and directories currently installed.) 66s Preparing to unpack .../00-sensible-utils_0.0.25_all.deb ... 66s Unpacking sensible-utils (0.0.25) over (0.0.24) ... 66s Preparing to unpack .../01-dhcpcd-base_1%3a10.1.0-10_armhf.deb ... 66s Unpacking dhcpcd-base (1:10.1.0-10) over (1:10.1.0-8) ... 66s Preparing to unpack .../02-distro-info-data_0.64_all.deb ... 66s Unpacking distro-info-data (0.64) over (0.63) ... 66s Preparing to unpack .../03-gir1.2-glib-2.0_2.84.1-2_armhf.deb ... 66s Unpacking gir1.2-glib-2.0:armhf (2.84.1-2) over (2.84.1-1) ... 66s Preparing to unpack .../04-libglib2.0-0t64_2.84.1-2_armhf.deb ... 66s Unpacking libglib2.0-0t64:armhf (2.84.1-2) over (2.84.1-1) ... 66s Preparing to unpack .../05-iso-codes_4.18.0-1_all.deb ... 66s Unpacking iso-codes (4.18.0-1) over (4.17.0-1) ... 67s Preparing to unpack .../06-less_668-1_armhf.deb ... 67s Unpacking less (668-1) over (643-1) ... 67s Preparing to unpack .../07-libelf1t64_0.193-1_armhf.deb ... 67s Unpacking libelf1t64:armhf (0.193-1) over (0.192-4ubuntu1) ... 67s Preparing to unpack .../08-libbpf1_1%3a1.5.0-3_armhf.deb ... 67s Unpacking libbpf1:armhf (1:1.5.0-3) over (1:1.5.0-2) ... 67s Preparing to unpack .../09-libglib2.0-data_2.84.1-2_all.deb ... 67s Unpacking libglib2.0-data (2.84.1-2) over (2.84.1-1) ... 67s Preparing to unpack .../10-libunistring5_1.3-2_armhf.deb ... 67s Unpacking libunistring5:armhf (1.3-2) over (1.3-1) ... 67s Preparing to unpack .../11-libxml2_2.12.7+dfsg+really2.9.14-0.4ubuntu0.1_armhf.deb ... 67s Unpacking libxml2:armhf (2.12.7+dfsg+really2.9.14-0.4ubuntu0.1) over (2.12.7+dfsg+really2.9.14-0.4) ... 67s Preparing to unpack .../12-netbase_6.5_all.deb ... 67s Unpacking netbase (6.5) over (6.4) ... 67s Preparing to unpack .../13-netcat-openbsd_1.229-1_armhf.deb ... 67s Unpacking netcat-openbsd (1.229-1) over (1.228-1) ... 67s Preparing to unpack .../14-python3-dbus_1.4.0-1_armhf.deb ... 67s Unpacking python3-dbus (1.4.0-1) over (1.3.2-5build5) ... 67s Preparing to unpack .../15-ubuntu-pro-client-l10n_35.1ubuntu0_armhf.deb ... 67s Unpacking ubuntu-pro-client-l10n (35.1ubuntu0) over (35) ... 67s Preparing to unpack .../16-ubuntu-pro-client_35.1ubuntu0_armhf.deb ... 68s Unpacking ubuntu-pro-client (35.1ubuntu0) over (35) ... 68s Preparing to unpack .../17-ed_1.21.1-1_armhf.deb ... 68s Unpacking ed (1.21.1-1) over (1.21-1) ... 68s Preparing to unpack .../18-ethtool_1%3a6.14-2_armhf.deb ... 68s Unpacking ethtool (1:6.14-2) over (1:6.11-1) ... 68s Preparing to unpack .../19-gettext-base_0.23.1-2_armhf.deb ... 68s Unpacking gettext-base (0.23.1-2) over (0.23.1-1) ... 68s Preparing to unpack .../20-groff-base_1.23.0-8_armhf.deb ... 68s Unpacking groff-base (1.23.0-8) over (1.23.0-7) ... 68s Preparing to unpack .../21-libevdev2_1.13.4+dfsg-1_armhf.deb ... 68s Unpacking libevdev2:armhf (1.13.4+dfsg-1) over (1.13.3+dfsg-1) ... 68s Preparing to unpack .../22-libnftnl11_1.2.9-1_armhf.deb ... 68s Unpacking libnftnl11:armhf (1.2.9-1) over (1.2.8-1) ... 68s Preparing to unpack .../23-libnghttp2-14_1.64.0-1.1_armhf.deb ... 68s Unpacking libnghttp2-14:armhf (1.64.0-1.1) over (1.64.0-1ubuntu1) ... 68s Preparing to unpack .../24-libnuma1_2.0.19-1_armhf.deb ... 68s Unpacking libnuma1:armhf (2.0.19-1) over (2.0.18-1build1) ... 68s Preparing to unpack .../25-libsensors-config_1%3a3.6.2-2_all.deb ... 68s Unpacking libsensors-config (1:3.6.2-2) over (1:3.6.0-10) ... 68s Preparing to unpack .../26-libsensors5_1%3a3.6.2-2_armhf.deb ... 68s Unpacking libsensors5:armhf (1:3.6.2-2) over (1:3.6.0-10) ... 68s Preparing to unpack .../27-liburcu8t64_0.15.2-2_armhf.deb ... 68s Unpacking liburcu8t64:armhf (0.15.2-2) over (0.15.1-1) ... 68s Preparing to unpack .../28-libusb-1.0-0_2%3a1.0.28-1_armhf.deb ... 68s Unpacking libusb-1.0-0:armhf (2:1.0.28-1) over (2:1.0.27-2) ... 68s Preparing to unpack .../29-libx11-data_2%3a1.8.12-1_all.deb ... 68s Unpacking libx11-data (2:1.8.12-1) over (2:1.8.10-2) ... 69s Preparing to unpack .../30-libx11-6_2%3a1.8.12-1_armhf.deb ... 69s Unpacking libx11-6:armhf (2:1.8.12-1) over (2:1.8.10-2) ... 69s Preparing to unpack .../31-man-db_2.13.1-1_armhf.deb ... 69s Unpacking man-db (2.13.1-1) over (2.13.0-1) ... 69s Preparing to unpack .../32-nano_8.4-1_armhf.deb ... 69s Unpacking nano (8.4-1) over (8.3-1) ... 69s Preparing to unpack .../33-numactl_2.0.19-1_armhf.deb ... 69s Unpacking numactl (2.0.19-1) over (2.0.18-1build1) ... 69s Preparing to unpack .../34-publicsuffix_20250328.1952-0.1_all.deb ... 69s Unpacking publicsuffix (20250328.1952-0.1) over (20250108.1153-0.1) ... 69s Preparing to unpack .../35-usb.ids_2025.04.01-1_all.deb ... 69s Unpacking usb.ids (2025.04.01-1) over (2025.01.14-1) ... 69s Preparing to unpack .../36-usbutils_1%3a018-2_armhf.deb ... 69s Unpacking usbutils (1:018-2) over (1:018-1) ... 69s Preparing to unpack .../37-btrfs-progs_6.14-1_armhf.deb ... 69s Unpacking btrfs-progs (6.14-1) over (6.12-1build1) ... 69s Preparing to unpack .../38-cloud-init-base_25.2~1g7a0265d3-0ubuntu1_all.deb ... 70s Unpacking cloud-init-base (25.2~1g7a0265d3-0ubuntu1) over (25.1.1-0ubuntu2) ... 70s Preparing to unpack .../39-dpkg-dev_1.22.18ubuntu3_all.deb ... 70s Unpacking dpkg-dev (1.22.18ubuntu3) over (1.22.18ubuntu2) ... 70s Preparing to unpack .../40-libdpkg-perl_1.22.18ubuntu3_all.deb ... 70s Unpacking libdpkg-perl (1.22.18ubuntu3) over (1.22.18ubuntu2) ... 70s Preparing to unpack .../41-patch_2.8-1_armhf.deb ... 70s Unpacking patch (2.8-1) over (2.7.6-7build3) ... 70s Preparing to unpack .../42-lto-disabled-list_58_all.deb ... 70s Unpacking lto-disabled-list (58) over (57) ... 70s Preparing to unpack .../43-libjcat1_0.2.3-1_armhf.deb ... 70s Unpacking libjcat1:armhf (0.2.3-1) over (0.2.0-2build3) ... 71s Preparing to unpack .../44-fwupd_2.0.8-3_armhf.deb ... 71s Unpacking fwupd (2.0.8-3) over (2.0.7-1) ... 71s dpkg: warning: unable to delete old directory '/etc/grub.d': Directory not empty 71s Preparing to unpack .../45-libfwupd3_2.0.8-3_armhf.deb ... 71s Unpacking libfwupd3:armhf (2.0.8-3) over (2.0.7-1) ... 71s Preparing to unpack .../46-libmbim-proxy_1.32.0-1_armhf.deb ... 71s Unpacking libmbim-proxy (1.32.0-1) over (1.31.2-0ubuntu4) ... 71s Preparing to unpack .../47-libmbim-glib4_1.32.0-1_armhf.deb ... 71s Unpacking libmbim-glib4:armhf (1.32.0-1) over (1.31.2-0ubuntu4) ... 71s Preparing to unpack .../48-libmm-glib0_1.24.0-1_armhf.deb ... 71s Unpacking libmm-glib0:armhf (1.24.0-1) over (1.23.4-0ubuntu3) ... 71s Preparing to unpack .../49-libqmi-proxy_1.36.0-1_armhf.deb ... 71s Unpacking libqmi-proxy (1.36.0-1) over (1.35.6-1) ... 71s Preparing to unpack .../50-libqmi-glib5_1.36.0-1_armhf.deb ... 71s Unpacking libqmi-glib5:armhf (1.36.0-1) over (1.35.6-1) ... 71s Preparing to unpack .../51-gnupg-l10n_2.4.4-2ubuntu24_all.deb ... 71s Unpacking gnupg-l10n (2.4.4-2ubuntu24) over (2.4.4-2ubuntu23) ... 71s Preparing to unpack .../52-htop_3.4.1-4_armhf.deb ... 71s Unpacking htop (3.4.1-4) over (3.4.0-2) ... 72s Preparing to unpack .../53-libftdi1-2_1.5-10_armhf.deb ... 72s Unpacking libftdi1-2:armhf (1.5-10) over (1.5-8build1) ... 72s Preparing to unpack .../54-libnvme1t64_1.13-2_armhf.deb ... 72s Unpacking libnvme1t64 (1.13-2) over (1.11.1-2) ... 72s Preparing to unpack .../55-python3-attr_25.3.0-1_all.deb ... 72s Unpacking python3-attr (25.3.0-1) over (25.1.0-1) ... 72s Preparing to unpack .../56-python3-wadllib_2.0.0-3_all.deb ... 72s Unpacking python3-wadllib (2.0.0-3) over (2.0.0-2) ... 72s Preparing to unpack .../57-python3-lazr.restfulclient_0.14.6-3_all.deb ... 72s Unpacking python3-lazr.restfulclient (0.14.6-3) over (0.14.6-2) ... 72s Preparing to unpack .../58-python3-more-itertools_10.7.0-1_all.deb ... 72s Unpacking python3-more-itertools (10.7.0-1) over (10.6.0-1) ... 72s Preparing to unpack .../59-python3-packaging_25.0-1_all.deb ... 72s Unpacking python3-packaging (25.0-1) over (24.2-1) ... 72s Preparing to unpack .../60-python3-s3transfer_0.11.4-1_all.deb ... 73s Unpacking python3-s3transfer (0.11.4-1) over (0.11.2-2) ... 73s Preparing to unpack .../61-sos_4.9.1-1_all.deb ... 73s Unpacking sos (4.9.1-1) over (4.9.0-6) ... 73s Preparing to unpack .../62-cloud-init_25.2~1g7a0265d3-0ubuntu1_all.deb ... 73s Unpacking cloud-init (25.2~1g7a0265d3-0ubuntu1) over (25.1.1-0ubuntu2) ... 73s Setting up motd-news-config (13.7ubuntu1) ... 73s Setting up python3-more-itertools (10.7.0-1) ... 73s Setting up python3-attr (25.3.0-1) ... 74s Setting up liburcu8t64:armhf (0.15.2-2) ... 74s Setting up lto-disabled-list (58) ... 74s Setting up distro-info-data (0.64) ... 74s Setting up htop (3.4.1-4) ... 74s Setting up openssh-client (1:9.9p1-3ubuntu3.1) ... 74s Setting up btrfs-progs (6.14-1) ... 74s Setting up python3-s3transfer (0.11.4-1) ... 74s Setting up netcat-openbsd (1.229-1) ... 74s Setting up libsensors-config (1:3.6.2-2) ... 74s Installing new version of config file /etc/sensors3.conf ... 74s Setting up libnghttp2-14:armhf (1.64.0-1.1) ... 74s Setting up less (668-1) ... 74s Setting up gettext-base (0.23.1-2) ... 74s Setting up libnftnl11:armhf (1.2.9-1) ... 74s Setting up libelf1t64:armhf (0.193-1) ... 74s Setting up libglib2.0-data (2.84.1-2) ... 74s Setting up python3-packaging (25.0-1) ... 74s Setting up libnvme1t64 (1.13-2) ... 74s Setting up libx11-data (2:1.8.12-1) ... 74s Setting up gnupg-l10n (2.4.4-2ubuntu24) ... 74s Setting up ed (1.21.1-1) ... 74s Setting up python3-wadllib (2.0.0-3) ... 74s Setting up libunistring5:armhf (1.3-2) ... 74s Setting up libatomic1:armhf (15.1.0-2ubuntu1) ... 74s Setting up patch (2.8-1) ... 74s Setting up usb.ids (2025.04.01-1) ... 74s Setting up dhcpcd-base (1:10.1.0-10) ... 74s Installing new version of config file /etc/dhcpcd.conf ... 74s Setting up libsensors5:armhf (1:3.6.2-2) ... 74s Setting up nano (8.4-1) ... 74s Installing new version of config file /etc/nanorc ... 74s Setting up libnuma1:armhf (2.0.19-1) ... 74s Setting up perl-modules-5.40 (5.40.1-3) ... 74s Setting up sensible-utils (0.0.25) ... 74s Setting up groff-base (1.23.0-8) ... 74s Setting up gpgconf (2.4.4-2ubuntu24) ... 74s Setting up libx11-6:armhf (2:1.8.12-1) ... 74s Setting up netbase (6.5) ... 74s Installing new version of config file /etc/ethertypes ... 74s Installing new version of config file /etc/services ... 75s Setting up libusb-1.0-0:armhf (2:1.0.28-1) ... 75s Setting up python3-lazr.restfulclient (0.14.6-3) ... 75s Setting up libgpg-error-l10n (1.51-4) ... 75s Setting up libevdev2:armhf (1.13.4+dfsg-1) ... 75s Setting up publicsuffix (20250328.1952-0.1) ... 75s Setting up libxml2:armhf (2.12.7+dfsg+really2.9.14-0.4ubuntu0.1) ... 75s Setting up ubuntu-pro-client (35.1ubuntu0) ... 75s apparmor_parser: Unable to replace "ubuntu_pro_apt_news". apparmor_parser: Access denied. You need policy admin privileges to manage profiles. 75s 75s apparmor_parser: Unable to replace "apt_methods". apparmor_parser: Access denied. You need policy admin privileges to manage profiles. 75s 75s apparmor_parser: Unable to replace "ubuntu_pro_esm_cache". apparmor_parser: Access denied. You need policy admin privileges to manage profiles. 75s 77s Setting up iso-codes (4.18.0-1) ... 77s Setting up gpg (2.4.4-2ubuntu24) ... 77s Setting up libbpf1:armhf (1:1.5.0-3) ... 77s Setting up ethtool (1:6.14-2) ... 77s Setting up gnupg-utils (2.4.4-2ubuntu24) ... 77s Setting up ubuntu-pro-client-l10n (35.1ubuntu0) ... 77s Setting up sos (4.9.1-1) ... 78s Setting up openssh-sftp-server (1:9.9p1-3ubuntu3.1) ... 78s Setting up gpg-agent (2.4.4-2ubuntu24) ... 78s Setting up numactl (2.0.19-1) ... 78s Setting up openssh-server (1:9.9p1-3ubuntu3.1) ... 80s Setting up gpgsm (2.4.4-2ubuntu24) ... 80s Setting up man-db (2.13.1-1) ... 80s Updating database of manual pages ... 82s apparmor_parser: Unable to replace "/usr/bin/man". apparmor_parser: Access denied. You need policy admin privileges to manage profiles. 82s 83s man-db.service is a disabled or a static unit not running, not starting it. 83s Setting up usbutils (1:018-2) ... 83s Setting up cloud-init-base (25.2~1g7a0265d3-0ubuntu1) ... 85s Setting up libperl5.40:armhf (5.40.1-3) ... 85s Setting up dirmngr (2.4.4-2ubuntu24) ... 85s Setting up libftdi1-2:armhf (1.5-10) ... 85s Setting up perl (5.40.1-3) ... 85s Setting up libglib2.0-0t64:armhf (2.84.1-2) ... 85s No schema files found: doing nothing. 85s Setting up keyboxd (2.4.4-2ubuntu24) ... 85s Setting up gir1.2-glib-2.0:armhf (2.84.1-2) ... 85s Setting up libdpkg-perl (1.22.18ubuntu3) ... 85s Setting up libmm-glib0:armhf (1.24.0-1) ... 85s Setting up gnupg (2.4.4-2ubuntu24) ... 85s Setting up libmbim-glib4:armhf (1.32.0-1) ... 85s Setting up python3-dbus (1.4.0-1) ... 85s Setting up cloud-init (25.2~1g7a0265d3-0ubuntu1) ... 85s Setting up gpg-wks-client (2.4.4-2ubuntu24) ... 85s Setting up libmbim-proxy (1.32.0-1) ... 85s Setting up libjcat1:armhf (0.2.3-1) ... 85s Setting up dpkg-dev (1.22.18ubuntu3) ... 85s Setting up libqmi-glib5:armhf (1.36.0-1) ... 85s Setting up libfwupd3:armhf (2.0.8-3) ... 85s Setting up libqmi-proxy (1.36.0-1) ... 85s Setting up fwupd (2.0.8-3) ... 86s fwupd-refresh.service is a disabled or a static unit not running, not starting it. 86s fwupd.service is a disabled or a static unit not running, not starting it. 86s Processing triggers for libc-bin (2.41-6ubuntu1) ... 87s Processing triggers for rsyslog (8.2412.0-2ubuntu2) ... 87s Processing triggers for ufw (0.36.2-9) ... 87s Processing triggers for plymouth-theme-ubuntu-text (24.004.60-2ubuntu7) ... 87s Processing triggers for dbus (1.16.2-2ubuntu1) ... 87s Processing triggers for install-info (7.1.1-1) ... 87s Processing triggers for initramfs-tools (0.147ubuntu1) ... 89s Reading package lists... 90s Building dependency tree... 90s Reading state information... 90s Starting pkgProblemResolver with broken count: 0 90s Starting 2 pkgProblemResolver with broken count: 0 90s Done 91s Solving dependencies... 92s 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 94s autopkgtest [17:25:13]: rebooting testbed after setup commands that affected boot 133s autopkgtest [17:25:52]: testbed running kernel: Linux 6.8.0-58-generic #60~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Mar 28 14:48:37 UTC 2 157s autopkgtest [17:26:16]: @@@@@@@@@@@@@@@@@@@@ apt-source pandas 174s Get:1 http://ftpmaster.internal/ubuntu questing/universe pandas 2.2.3+dfsg-9 (dsc) [5546 B] 174s Get:2 http://ftpmaster.internal/ubuntu questing/universe pandas 2.2.3+dfsg-9 (tar) [11.2 MB] 174s Get:3 http://ftpmaster.internal/ubuntu questing/universe pandas 2.2.3+dfsg-9 (diff) [112 kB] 174s gpgv: Signature made Sat Mar 29 14:46:18 2025 UTC 174s gpgv: using RSA key 67CB311005C4EDBE32175308DEE50D0D567EA266 174s gpgv: issuer "rebecca_palmer@zoho.com" 174s gpgv: Can't check signature: No public key 174s dpkg-source: warning: cannot verify inline signature for ./pandas_2.2.3+dfsg-9.dsc: no acceptable signature found 176s autopkgtest [17:26:35]: testing package pandas version 2.2.3+dfsg-9 178s autopkgtest [17:26:37]: build not needed 182s autopkgtest [17:26:41]: test command1: preparing testbed 184s Reading package lists... 185s Building dependency tree... 185s Reading state information... 185s Starting pkgProblemResolver with broken count: 0 185s Starting 2 pkgProblemResolver with broken count: 0 185s Done 186s The following NEW packages will be installed: 186s libblas3 libgfortran5 liblapack3 python3-numpy python3-numpy-dev 186s python3-pandas python3-pandas-lib python3-pytz 187s 0 upgraded, 8 newly installed, 0 to remove and 0 not upgraded. 187s Need to get 14.6 MB of archives. 187s After this operation, 64.4 MB of additional disk space will be used. 187s Get:1 http://ftpmaster.internal/ubuntu questing/main armhf python3-numpy-dev armhf 1:2.2.4+ds-1 [141 kB] 187s Get:2 http://ftpmaster.internal/ubuntu questing/main armhf libblas3 armhf 3.12.1-2 [132 kB] 187s Get:3 http://ftpmaster.internal/ubuntu questing/main armhf libgfortran5 armhf 15.1.0-2ubuntu1 [331 kB] 187s Get:4 http://ftpmaster.internal/ubuntu questing/main armhf liblapack3 armhf 3.12.1-2 [2091 kB] 187s Get:5 http://ftpmaster.internal/ubuntu questing/main armhf python3-numpy armhf 1:2.2.4+ds-1 [3732 kB] 187s Get:6 http://ftpmaster.internal/ubuntu questing/main armhf python3-pytz all 2025.1-3 [162 kB] 187s Get:7 http://ftpmaster.internal/ubuntu questing/universe armhf python3-pandas-lib armhf 2.2.3+dfsg-9 [4884 kB] 187s Get:8 http://ftpmaster.internal/ubuntu questing/universe armhf python3-pandas all 2.2.3+dfsg-9 [3112 kB] 188s Fetched 14.6 MB in 1s (14.9 MB/s) 188s Selecting previously unselected package python3-numpy-dev:armhf. 188s (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 ... 63964 files and directories currently installed.) 188s Preparing to unpack .../0-python3-numpy-dev_1%3a2.2.4+ds-1_armhf.deb ... 188s Unpacking python3-numpy-dev:armhf (1:2.2.4+ds-1) ... 188s Selecting previously unselected package libblas3:armhf. 188s Preparing to unpack .../1-libblas3_3.12.1-2_armhf.deb ... 188s Unpacking libblas3:armhf (3.12.1-2) ... 188s Selecting previously unselected package libgfortran5:armhf. 188s Preparing to unpack .../2-libgfortran5_15.1.0-2ubuntu1_armhf.deb ... 188s Unpacking libgfortran5:armhf (15.1.0-2ubuntu1) ... 188s Selecting previously unselected package liblapack3:armhf. 188s Preparing to unpack .../3-liblapack3_3.12.1-2_armhf.deb ... 188s Unpacking liblapack3:armhf (3.12.1-2) ... 188s Selecting previously unselected package python3-numpy. 188s Preparing to unpack .../4-python3-numpy_1%3a2.2.4+ds-1_armhf.deb ... 188s Unpacking python3-numpy (1:2.2.4+ds-1) ... 189s Selecting previously unselected package python3-pytz. 189s Preparing to unpack .../5-python3-pytz_2025.1-3_all.deb ... 189s Unpacking python3-pytz (2025.1-3) ... 189s Selecting previously unselected package python3-pandas-lib:armhf. 189s Preparing to unpack .../6-python3-pandas-lib_2.2.3+dfsg-9_armhf.deb ... 189s Unpacking python3-pandas-lib:armhf (2.2.3+dfsg-9) ... 189s Selecting previously unselected package python3-pandas. 189s Preparing to unpack .../7-python3-pandas_2.2.3+dfsg-9_all.deb ... 189s Unpacking python3-pandas (2.2.3+dfsg-9) ... 189s Setting up python3-pytz (2025.1-3) ... 189s Setting up libblas3:armhf (3.12.1-2) ... 189s update-alternatives: using /usr/lib/arm-linux-gnueabihf/blas/libblas.so.3 to provide /usr/lib/arm-linux-gnueabihf/libblas.so.3 (libblas.so.3-arm-linux-gnueabihf) in auto mode 190s Setting up python3-numpy-dev:armhf (1:2.2.4+ds-1) ... 190s Setting up libgfortran5:armhf (15.1.0-2ubuntu1) ... 190s Setting up liblapack3:armhf (3.12.1-2) ... 190s update-alternatives: using /usr/lib/arm-linux-gnueabihf/lapack/liblapack.so.3 to provide /usr/lib/arm-linux-gnueabihf/liblapack.so.3 (liblapack.so.3-arm-linux-gnueabihf) in auto mode 190s Setting up python3-numpy (1:2.2.4+ds-1) ... 192s Setting up python3-pandas-lib:armhf (2.2.3+dfsg-9) ... 192s Setting up python3-pandas (2.2.3+dfsg-9) ... 200s Processing triggers for man-db (2.13.1-1) ... 200s Processing triggers for libc-bin (2.41-6ubuntu1) ... 208s autopkgtest [17:27:07]: test command1: cd "$AUTOPKGTEST_TMP" && python3 -c "import pandas;a=pandas.DataFrame([[1,2],[3,4]])" 208s autopkgtest [17:27:07]: test command1: [----------------------- 211s autopkgtest [17:27:10]: test command1: -----------------------] 215s command1 PASS 215s autopkgtest [17:27:14]: test command1: - - - - - - - - - - results - - - - - - - - - - 218s autopkgtest [17:27:17]: test unittests3: preparing testbed 220s Reading package lists... 221s Building dependency tree... 221s Reading state information... 221s Starting pkgProblemResolver with broken count: 0 221s Starting 2 pkgProblemResolver with broken count: 0 221s Done 222s The following NEW packages will be installed: 222s blt fontconfig fontconfig-config fonts-dejavu-core fonts-dejavu-mono 222s fonts-lyx libaec0 libavahi-client3 libavahi-common-data libavahi-common3 222s libblosc1 libblosc2-4 libcups2t64 libdeflate0 libdouble-conversion3 222s libegl-mesa0 libegl1 libfontconfig1 libfontenc1 libfreetype6 libgbm1 libgl1 222s libgl1-mesa-dri libgles2 libglvnd0 libglx-mesa0 libglx0 libgomp1 222s libgraphite2-3 libharfbuzz0b libhdf5-310 libice6 libimagequant0 libinput-bin 222s libinput10 libjbig0 libjpeg-turbo8 libjpeg8 libjs-jquery libjs-jquery-ui 222s liblbfgsb0 liblcms2-2 liblerc4 libllvm19 libmd4c0 libmtdev1t64 libopenjp2-7 222s libpcre2-16-0 libpixman-1-0 libpython3.13 libqhull-r8.0 libqt5core5t64 222s libqt5dbus5t64 libqt5designer5 libqt5gui5t64 libqt5help5 libqt5network5t64 222s libqt5printsupport5t64 libqt5sql5t64 libqt5test5t64 libqt5widgets5t64 222s libqt5xml5t64 libraqm0 libsharpyuv0 libsm6 libsnappy1v5 libsz2 libtcl8.6 222s libtiff6 libtk8.6 libvulkan1 libwacom-common libwacom9 libwayland-client0 222s libwayland-server0 libwebp7 libwebpdemux2 libwebpmux3 libx11-xcb1 libxaw7 222s libxcb-dri3-0 libxcb-glx0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 222s libxcb-present0 libxcb-randr0 libxcb-render-util0 libxcb-render0 222s libxcb-shape0 libxcb-shm0 libxcb-sync1 libxcb-util1 libxcb-xfixes0 222s libxcb-xinerama0 libxcb-xinput0 libxcb-xkb1 libxfont2 libxft2 222s libxkbcommon-x11-0 libxkbfile1 libxmu6 libxpm4 libxrandr2 libxrender1 222s libxshmfence1 libxslt1.1 libxss1 libxt6t64 libxxf86vm1 locales-all 222s mesa-libgallium python-matplotlib-data python-tables-data python3-all 222s python3-async-generator python3-bottleneck python3-brotli python3-bs4 222s python3-click python3-cloudpickle python3-contourpy python3-cpuinfo 222s python3-cycler python3-dask python3-decorator python3-defusedxml 222s python3-et-xmlfile python3-execnet python3-fonttools python3-fs 222s python3-fsspec python3-greenlet python3-html5lib python3-hypothesis 222s python3-iniconfig python3-kiwisolver python3-locket python3-lxml python3-lz4 222s python3-matplotlib python3-mpmath python3-numexpr python3-odf 222s python3-openpyxl python3-partd python3-pil python3-pil.imagetk 222s python3-platformdirs python3-pluggy python3-py python3-pyqt5 222s python3-pyqt5.sip python3-pyreadstat python3-pytest python3-pytest-asyncio 222s python3-pytest-forked python3-pytest-localserver python3-pytest-xdist 222s python3-pytestqt python3-scipy python3-sortedcontainers python3-soupsieve 222s python3-sqlalchemy python3-sympy python3-tables python3-tables-lib 222s python3-tabulate python3-tk python3-toolz python3-tz python3-ufolib2 222s python3-webencodings python3-werkzeug python3-xarray python3-xlrd 222s python3-xlsxwriter python3-zstandard python3.13-tk tk8.6-blt2.5 222s tzdata-legacy unicode-data x11-common x11-xkb-utils xsel xserver-common xvfb 222s 0 upgraded, 187 newly installed, 0 to remove and 0 not upgraded. 222s Need to get 138 MB of archives. 222s After this operation, 731 MB of additional disk space will be used. 222s Get:1 http://ftpmaster.internal/ubuntu questing/main armhf libtcl8.6 armhf 8.6.16+dfsg-1 [909 kB] 223s Get:2 http://ftpmaster.internal/ubuntu questing/main armhf libfreetype6 armhf 2.13.3+dfsg-1 [330 kB] 223s Get:3 http://ftpmaster.internal/ubuntu questing/main armhf fonts-dejavu-mono all 2.37-8 [502 kB] 223s Get:4 http://ftpmaster.internal/ubuntu questing/main armhf fonts-dejavu-core all 2.37-8 [835 kB] 223s Get:5 http://ftpmaster.internal/ubuntu questing/main armhf fontconfig-config armhf 2.15.0-2.2ubuntu1 [37.9 kB] 223s Get:6 http://ftpmaster.internal/ubuntu questing/main armhf libfontconfig1 armhf 2.15.0-2.2ubuntu1 [114 kB] 223s Get:7 http://ftpmaster.internal/ubuntu questing/main armhf libxrender1 armhf 1:0.9.12-1 [16.6 kB] 223s Get:8 http://ftpmaster.internal/ubuntu questing/main armhf libxft2 armhf 2.3.6-1build1 [37.4 kB] 223s Get:9 http://ftpmaster.internal/ubuntu questing/main armhf x11-common all 1:7.7+23ubuntu4 [21.8 kB] 223s Get:10 http://ftpmaster.internal/ubuntu questing/main armhf libxss1 armhf 1:1.2.3-1build3 [6500 B] 223s Get:11 http://ftpmaster.internal/ubuntu questing/main armhf libtk8.6 armhf 8.6.16-1 [686 kB] 223s Get:12 http://ftpmaster.internal/ubuntu questing/main armhf tk8.6-blt2.5 armhf 2.5.3+dfsg-8 [527 kB] 224s Get:13 http://ftpmaster.internal/ubuntu questing/main armhf blt armhf 2.5.3+dfsg-8 [4824 B] 224s Get:14 http://ftpmaster.internal/ubuntu questing/main armhf fontconfig armhf 2.15.0-2.2ubuntu1 [190 kB] 224s Get:15 http://ftpmaster.internal/ubuntu questing/universe armhf fonts-lyx all 2.4.3-1 [171 kB] 224s Get:16 http://ftpmaster.internal/ubuntu questing/universe armhf libaec0 armhf 1.1.3-1 [20.8 kB] 224s Get:17 http://ftpmaster.internal/ubuntu questing/main armhf libavahi-common-data armhf 0.8-16ubuntu2 [31.0 kB] 224s Get:18 http://ftpmaster.internal/ubuntu questing/main armhf libavahi-common3 armhf 0.8-16ubuntu2 [20.2 kB] 224s Get:19 http://ftpmaster.internal/ubuntu questing/main armhf libavahi-client3 armhf 0.8-16ubuntu2 [24.5 kB] 224s Get:20 http://ftpmaster.internal/ubuntu questing/main armhf libsnappy1v5 armhf 1.2.2-1 [28.8 kB] 224s Get:21 http://ftpmaster.internal/ubuntu questing/universe armhf libblosc1 armhf 1.21.5+ds-1build1 [23.7 kB] 224s Get:22 http://ftpmaster.internal/ubuntu questing/universe armhf libblosc2-4 armhf 2.17.1+ds-1 [194 kB] 224s Get:23 http://ftpmaster.internal/ubuntu questing/main armhf libcups2t64 armhf 2.4.12-0ubuntu1 [240 kB] 224s Get:24 http://ftpmaster.internal/ubuntu questing/main armhf libdeflate0 armhf 1.23-2 [38.7 kB] 224s Get:25 http://ftpmaster.internal/ubuntu questing/universe armhf libdouble-conversion3 armhf 3.3.1-1 [39.1 kB] 224s Get:26 http://ftpmaster.internal/ubuntu questing/main armhf libwayland-server0 armhf 1.23.1-3 [30.3 kB] 224s Get:27 http://ftpmaster.internal/ubuntu questing/main armhf libllvm19 armhf 1:19.1.7-3ubuntu1 [27.8 MB] 225s Get:28 http://ftpmaster.internal/ubuntu questing/main armhf libx11-xcb1 armhf 2:1.8.12-1 [7916 B] 225s Get:29 http://ftpmaster.internal/ubuntu questing/main armhf libxcb-dri3-0 armhf 1.17.0-2 [7120 B] 225s Get:30 http://ftpmaster.internal/ubuntu questing/main armhf libxcb-present0 armhf 1.17.0-2 [5940 B] 225s Get:31 http://ftpmaster.internal/ubuntu questing/main armhf libxcb-randr0 armhf 1.17.0-2 [17.0 kB] 225s Get:32 http://ftpmaster.internal/ubuntu questing/main armhf libxcb-sync1 armhf 1.17.0-2 [8732 B] 225s Get:33 http://ftpmaster.internal/ubuntu questing/main armhf libxcb-xfixes0 armhf 1.17.0-2 [10.0 kB] 225s Get:34 http://ftpmaster.internal/ubuntu questing/main armhf libxshmfence1 armhf 1.3.3-1 [4948 B] 225s Get:35 http://ftpmaster.internal/ubuntu questing/main armhf mesa-libgallium armhf 25.0.3-1ubuntu2 [8260 kB] 226s Get:36 http://ftpmaster.internal/ubuntu questing/main armhf libgbm1 armhf 25.0.3-1ubuntu2 [29.0 kB] 226s Get:37 http://ftpmaster.internal/ubuntu questing/main armhf libwayland-client0 armhf 1.23.1-3 [23.3 kB] 226s Get:38 http://ftpmaster.internal/ubuntu questing/main armhf libxcb-shm0 armhf 1.17.0-2 [5774 B] 226s Get:39 http://ftpmaster.internal/ubuntu questing/main armhf libegl-mesa0 armhf 25.0.3-1ubuntu2 [101 kB] 226s Get:40 http://ftpmaster.internal/ubuntu questing/main armhf libfontenc1 armhf 1:1.1.8-1build1 [11.5 kB] 226s Get:41 http://ftpmaster.internal/ubuntu questing/main armhf libvulkan1 armhf 1.4.309.0-1 [127 kB] 226s Get:42 http://ftpmaster.internal/ubuntu questing/main armhf libgl1-mesa-dri armhf 25.0.3-1ubuntu2 [32.0 kB] 226s Get:43 http://ftpmaster.internal/ubuntu questing/main armhf libxcb-glx0 armhf 1.17.0-2 [22.6 kB] 226s Get:44 http://ftpmaster.internal/ubuntu questing/main armhf libxxf86vm1 armhf 1:1.1.4-1build4 [8068 B] 226s Get:45 http://ftpmaster.internal/ubuntu questing/main armhf libglx-mesa0 armhf 25.0.3-1ubuntu2 [120 kB] 226s Get:46 http://ftpmaster.internal/ubuntu questing/main armhf libgomp1 armhf 15.1.0-2ubuntu1 [128 kB] 226s Get:47 http://ftpmaster.internal/ubuntu questing/main armhf libgraphite2-3 armhf 1.3.14-2ubuntu1 [64.8 kB] 226s Get:48 http://ftpmaster.internal/ubuntu questing/main armhf libharfbuzz0b armhf 10.2.0-1 [464 kB] 226s Get:49 http://ftpmaster.internal/ubuntu questing/universe armhf libsz2 armhf 1.1.3-1 [5302 B] 226s Get:50 http://ftpmaster.internal/ubuntu questing/universe armhf libhdf5-310 armhf 1.14.5+repack-3 [1410 kB] 226s Get:51 http://ftpmaster.internal/ubuntu questing/main armhf libice6 armhf 2:1.1.1-1 [36.5 kB] 226s Get:52 http://ftpmaster.internal/ubuntu questing/main armhf libimagequant0 armhf 2.18.0-1build1 [31.1 kB] 226s Get:53 http://ftpmaster.internal/ubuntu questing/main armhf libwacom-common all 2.14.0-1 [103 kB] 226s Get:54 http://ftpmaster.internal/ubuntu questing/main armhf libwacom9 armhf 2.14.0-1 [23.6 kB] 226s Get:55 http://ftpmaster.internal/ubuntu questing/main armhf libinput-bin armhf 1.28.1-1 [26.1 kB] 226s Get:56 http://ftpmaster.internal/ubuntu questing/main armhf libmtdev1t64 armhf 1.1.7-1 [13.0 kB] 226s Get:57 http://ftpmaster.internal/ubuntu questing/main armhf libinput10 armhf 1.28.1-1 [131 kB] 226s Get:58 http://ftpmaster.internal/ubuntu questing/main armhf libjpeg-turbo8 armhf 2.1.5-3ubuntu2 [127 kB] 226s Get:59 http://ftpmaster.internal/ubuntu questing/main armhf libjpeg8 armhf 8c-2ubuntu11 [2148 B] 226s Get:60 http://ftpmaster.internal/ubuntu questing/main armhf libjs-jquery all 3.6.1+dfsg+~3.5.14-1 [328 kB] 226s Get:61 http://ftpmaster.internal/ubuntu questing/universe armhf libjs-jquery-ui all 1.13.2+dfsg-1 [252 kB] 226s Get:62 http://ftpmaster.internal/ubuntu questing/universe armhf liblbfgsb0 armhf 3.0+dfsg.4-1build1 [27.4 kB] 226s Get:63 http://ftpmaster.internal/ubuntu questing/main armhf liblcms2-2 armhf 2.16-2 [137 kB] 226s Get:64 http://ftpmaster.internal/ubuntu questing/main armhf liblerc4 armhf 4.0.0+ds-5ubuntu1 [160 kB] 226s Get:65 http://ftpmaster.internal/ubuntu questing/universe armhf libmd4c0 armhf 0.5.2-2 [38.2 kB] 226s Get:66 http://ftpmaster.internal/ubuntu questing/main armhf libpcre2-16-0 armhf 10.45-1 [207 kB] 226s Get:67 http://ftpmaster.internal/ubuntu questing/main armhf libpixman-1-0 armhf 0.44.0-3 [183 kB] 226s Get:68 http://ftpmaster.internal/ubuntu questing/main armhf libpython3.13 armhf 3.13.3-1 [2082 kB] 226s Get:69 http://ftpmaster.internal/ubuntu questing/universe armhf libqhull-r8.0 armhf 2020.2-6build1 [173 kB] 226s Get:70 http://ftpmaster.internal/ubuntu questing/universe armhf libqt5core5t64 armhf 5.15.15+dfsg-4ubuntu1 [1768 kB] 226s Get:71 http://ftpmaster.internal/ubuntu questing/universe armhf libqt5dbus5t64 armhf 5.15.15+dfsg-4ubuntu1 [198 kB] 226s Get:72 http://ftpmaster.internal/ubuntu questing/main armhf libglvnd0 armhf 1.7.0-1build1 [83.7 kB] 226s Get:73 http://ftpmaster.internal/ubuntu questing/main armhf libegl1 armhf 1.7.0-1build1 [29.8 kB] 226s Get:74 http://ftpmaster.internal/ubuntu questing/main armhf libgles2 armhf 1.7.0-1build1 [18.0 kB] 226s Get:75 http://ftpmaster.internal/ubuntu questing/universe armhf libqt5network5t64 armhf 5.15.15+dfsg-4ubuntu1 [653 kB] 226s Get:76 http://ftpmaster.internal/ubuntu questing/main armhf libsm6 armhf 2:1.2.6-1 [15.3 kB] 226s Get:77 http://ftpmaster.internal/ubuntu questing/main armhf libxcb-icccm4 armhf 0.4.2-1 [9840 B] 226s Get:78 http://ftpmaster.internal/ubuntu questing/main armhf libxcb-util1 armhf 0.4.1-1 [9468 B] 226s Get:79 http://ftpmaster.internal/ubuntu questing/main armhf libxcb-image0 armhf 0.4.0-2build1 [9680 B] 226s Get:80 http://ftpmaster.internal/ubuntu questing/main armhf libxcb-keysyms1 armhf 0.4.1-1 [8076 B] 226s Get:81 http://ftpmaster.internal/ubuntu questing/main armhf libxcb-render0 armhf 1.17.0-2 [15.3 kB] 226s Get:82 http://ftpmaster.internal/ubuntu questing/main armhf libxcb-render-util0 armhf 0.3.10-1 [9444 B] 226s Get:83 http://ftpmaster.internal/ubuntu questing/main armhf libxcb-shape0 armhf 1.17.0-2 [6030 B] 226s Get:84 http://ftpmaster.internal/ubuntu questing/main armhf libxcb-xinerama0 armhf 1.17.0-2 [5212 B] 226s Get:85 http://ftpmaster.internal/ubuntu questing/main armhf libxcb-xinput0 armhf 1.17.0-2 [29.5 kB] 226s Get:86 http://ftpmaster.internal/ubuntu questing/main armhf libxcb-xkb1 armhf 1.17.0-2 [28.8 kB] 226s Get:87 http://ftpmaster.internal/ubuntu questing/main armhf libxkbcommon-x11-0 armhf 1.7.0-2 [13.6 kB] 226s Get:88 http://ftpmaster.internal/ubuntu questing/universe armhf libqt5gui5t64 armhf 5.15.15+dfsg-4ubuntu1 [2968 kB] 226s Get:89 http://ftpmaster.internal/ubuntu questing/universe armhf libqt5widgets5t64 armhf 5.15.15+dfsg-4ubuntu1 [2261 kB] 227s Get:90 http://ftpmaster.internal/ubuntu questing/universe armhf libqt5xml5t64 armhf 5.15.15+dfsg-4ubuntu1 [108 kB] 227s Get:91 http://ftpmaster.internal/ubuntu questing/universe armhf libqt5designer5 armhf 5.15.15-6build1 [2726 kB] 227s Get:92 http://ftpmaster.internal/ubuntu questing/universe armhf libqt5sql5t64 armhf 5.15.15+dfsg-4ubuntu1 [108 kB] 227s Get:93 http://ftpmaster.internal/ubuntu questing/universe armhf libqt5help5 armhf 5.15.15-6build1 [144 kB] 227s Get:94 http://ftpmaster.internal/ubuntu questing/universe armhf libqt5printsupport5t64 armhf 5.15.15+dfsg-4ubuntu1 [192 kB] 227s Get:95 http://ftpmaster.internal/ubuntu questing/universe armhf libqt5test5t64 armhf 5.15.15+dfsg-4ubuntu1 [136 kB] 227s Get:96 http://ftpmaster.internal/ubuntu questing/main armhf libraqm0 armhf 0.10.2-1 [12.4 kB] 227s Get:97 http://ftpmaster.internal/ubuntu questing/main armhf libsharpyuv0 armhf 1.5.0-0.1 [16.4 kB] 227s Get:98 http://ftpmaster.internal/ubuntu questing/main armhf libjbig0 armhf 2.1-6.1ubuntu2 [24.9 kB] 227s Get:99 http://ftpmaster.internal/ubuntu questing/main armhf libwebp7 armhf 1.5.0-0.1 [188 kB] 227s Get:100 http://ftpmaster.internal/ubuntu questing/main armhf libtiff6 armhf 4.7.0-3ubuntu1 [184 kB] 227s Get:101 http://ftpmaster.internal/ubuntu questing/main armhf libwebpdemux2 armhf 1.5.0-0.1 [11.5 kB] 227s Get:102 http://ftpmaster.internal/ubuntu questing/main armhf libwebpmux3 armhf 1.5.0-0.1 [22.4 kB] 227s Get:103 http://ftpmaster.internal/ubuntu questing/main armhf libxt6t64 armhf 1:1.2.1-1.2build1 [145 kB] 227s Get:104 http://ftpmaster.internal/ubuntu questing/main armhf libxmu6 armhf 2:1.1.3-3build2 [40.4 kB] 227s Get:105 http://ftpmaster.internal/ubuntu questing/main armhf libxpm4 armhf 1:3.5.17-1build2 [30.1 kB] 227s Get:106 http://ftpmaster.internal/ubuntu questing/main armhf libxaw7 armhf 2:1.0.16-1 [154 kB] 227s Get:107 http://ftpmaster.internal/ubuntu questing/main armhf libxfont2 armhf 1:2.0.6-1build1 [80.3 kB] 227s Get:108 http://ftpmaster.internal/ubuntu questing/main armhf libxkbfile1 armhf 1:1.1.0-1build4 [60.0 kB] 227s Get:109 http://ftpmaster.internal/ubuntu questing/main armhf libxrandr2 armhf 2:1.5.4-1 [15.8 kB] 227s Get:110 http://ftpmaster.internal/ubuntu questing/main armhf libxslt1.1 armhf 1.1.39-0exp1ubuntu4 [151 kB] 227s Get:111 http://ftpmaster.internal/ubuntu questing-proposed/universe armhf python-matplotlib-data all 3.10.1+dfsg1-3 [2936 kB] 227s Get:112 http://ftpmaster.internal/ubuntu questing/universe armhf python-tables-data all 3.10.2-2build1 [49.7 kB] 227s Get:113 http://ftpmaster.internal/ubuntu questing/main armhf python3-all armhf 3.13.3-1 [880 B] 227s Get:114 http://ftpmaster.internal/ubuntu questing/universe armhf python3-async-generator all 1.10-4 [17.5 kB] 227s Get:115 http://ftpmaster.internal/ubuntu questing/universe armhf python3-bottleneck armhf 1.4.2+ds1-2build1 [91.5 kB] 227s Get:116 http://ftpmaster.internal/ubuntu questing/universe armhf python3-brotli armhf 1.1.0-2build4 [322 kB] 227s Get:117 http://ftpmaster.internal/ubuntu questing/main armhf python3-soupsieve all 2.7-1 [33.5 kB] 227s Get:118 http://ftpmaster.internal/ubuntu questing/main armhf python3-bs4 all 4.13.4-1 [137 kB] 227s Get:119 http://ftpmaster.internal/ubuntu questing/main armhf python3-click all 8.2.0+0.really.8.1.8-1 [80.0 kB] 227s Get:120 http://ftpmaster.internal/ubuntu questing/universe armhf python3-cloudpickle all 3.1.1-1 [22.4 kB] 227s Get:121 http://ftpmaster.internal/ubuntu questing/universe armhf python3-contourpy armhf 1.3.1-1build1 [195 kB] 228s Get:122 http://ftpmaster.internal/ubuntu questing/universe armhf python3-cpuinfo all 9.0.0+git20221119-3 [21.7 kB] 228s Get:123 http://ftpmaster.internal/ubuntu questing/universe armhf python3-cycler all 0.12.1-1 [9716 B] 228s Get:124 http://ftpmaster.internal/ubuntu questing/universe armhf python3-fsspec all 2025.3.0-1 [216 kB] 228s Get:125 http://ftpmaster.internal/ubuntu questing/universe armhf python3-toolz all 1.0.0-2 [45.0 kB] 228s Get:126 http://ftpmaster.internal/ubuntu questing/universe armhf python3-locket all 1.0.0-2 [5872 B] 228s Get:127 http://ftpmaster.internal/ubuntu questing/universe armhf python3-partd all 1.4.2-1 [15.7 kB] 228s Get:128 http://ftpmaster.internal/ubuntu questing/universe armhf python3-dask all 2024.12.1+dfsg-2 [875 kB] 228s Get:129 http://ftpmaster.internal/ubuntu questing/main armhf python3-decorator all 5.2.1-2 [28.1 kB] 228s Get:130 http://ftpmaster.internal/ubuntu questing/main armhf python3-defusedxml all 0.7.1-3 [42.2 kB] 228s Get:131 http://ftpmaster.internal/ubuntu questing/universe armhf python3-et-xmlfile all 2.0.0-1 [79.4 kB] 228s Get:132 http://ftpmaster.internal/ubuntu questing/universe armhf python3-execnet all 2.1.1-1 [33.4 kB] 228s Get:133 http://ftpmaster.internal/ubuntu questing/main armhf python3-platformdirs all 4.3.7-1 [16.9 kB] 228s Get:134 http://ftpmaster.internal/ubuntu questing/universe armhf python3-fs all 2.4.16-7 [90.8 kB] 228s Get:135 http://ftpmaster.internal/ubuntu questing/main armhf python3-lxml armhf 5.4.0-1 [1280 kB] 228s Get:136 http://ftpmaster.internal/ubuntu questing/universe armhf python3-lz4 armhf 4.4.0+dfsg-2 [25.2 kB] 228s Get:137 http://ftpmaster.internal/ubuntu questing/universe armhf python3-scipy armhf 1.14.1-4ubuntu2 [16.7 MB] 228s Get:138 http://ftpmaster.internal/ubuntu questing/universe armhf python3-mpmath all 1.3.0-1 [425 kB] 228s Get:139 http://ftpmaster.internal/ubuntu questing/universe armhf python3-sympy all 1.13.3-5 [4229 kB] 228s Get:140 http://ftpmaster.internal/ubuntu questing/universe armhf python3-ufolib2 all 0.17.1+dfsg1-1 [33.5 kB] 228s Get:141 http://ftpmaster.internal/ubuntu questing/universe armhf unicode-data all 15.1.0-1 [8878 kB] 229s Get:142 http://ftpmaster.internal/ubuntu questing/universe armhf python3-fonttools armhf 4.55.3-2build1 [1462 kB] 229s Get:143 http://ftpmaster.internal/ubuntu questing/main armhf python3-webencodings all 0.5.1-5 [11.5 kB] 229s Get:144 http://ftpmaster.internal/ubuntu questing/main armhf python3-html5lib all 1.2-2 [90.6 kB] 229s Get:145 http://ftpmaster.internal/ubuntu questing/main armhf python3-sortedcontainers all 2.4.0-2 [27.6 kB] 229s Get:146 http://ftpmaster.internal/ubuntu questing/universe armhf python3-hypothesis all 6.127.4-1 [335 kB] 229s Get:147 http://ftpmaster.internal/ubuntu questing/universe armhf python3-iniconfig all 1.1.1-2 [6024 B] 229s Get:148 http://ftpmaster.internal/ubuntu questing/universe armhf python3-kiwisolver armhf 1.4.7-3build1 [57.7 kB] 229s Get:149 http://ftpmaster.internal/ubuntu questing/main armhf libopenjp2-7 armhf 2.5.3-2 [172 kB] 229s Get:150 http://ftpmaster.internal/ubuntu questing/main armhf python3-pil armhf 11.1.0-5build1 [435 kB] 229s Get:151 http://ftpmaster.internal/ubuntu questing/main armhf python3.13-tk armhf 3.13.3-1 [104 kB] 229s Get:152 http://ftpmaster.internal/ubuntu questing/main armhf python3-tk armhf 3.13.3-1 [9854 B] 229s Get:153 http://ftpmaster.internal/ubuntu questing/universe armhf python3-pil.imagetk armhf 11.1.0-5build1 [9226 B] 229s Get:154 http://ftpmaster.internal/ubuntu questing-proposed/universe armhf python3-matplotlib armhf 3.10.1+dfsg1-3 [18.0 MB] 229s Get:155 http://ftpmaster.internal/ubuntu questing/universe armhf python3-numexpr armhf 2.10.2-1build2 [118 kB] 229s Get:156 http://ftpmaster.internal/ubuntu questing/universe armhf python3-odf all 1.4.2-4 [79.0 kB] 229s Get:157 http://ftpmaster.internal/ubuntu questing/universe armhf python3-openpyxl all 3.1.5+dfsg-2 [152 kB] 229s Get:158 http://ftpmaster.internal/ubuntu questing/universe armhf python3-pluggy all 1.5.0-1 [21.0 kB] 229s Get:159 http://ftpmaster.internal/ubuntu questing/universe armhf python3-py all 1.11.0-4 [72.7 kB] 229s Get:160 http://ftpmaster.internal/ubuntu questing/universe armhf python3-pyqt5.sip armhf 12.17.0-1build1 [55.1 kB] 229s Get:161 http://ftpmaster.internal/ubuntu questing/universe armhf python3-pyqt5 armhf 5.15.11+dfsg-2 [2199 kB] 229s Get:162 http://ftpmaster.internal/ubuntu questing/universe armhf python3-pyreadstat armhf 1.2.8-1build1 [338 kB] 229s Get:163 http://ftpmaster.internal/ubuntu questing/universe armhf python3-pytest all 8.3.5-1 [252 kB] 229s Get:164 http://ftpmaster.internal/ubuntu questing/universe armhf python3-pytest-asyncio all 0.25.1-1 [17.0 kB] 229s Get:165 http://ftpmaster.internal/ubuntu questing/universe armhf python3-pytest-forked all 1.6.0-3 [7470 B] 229s Get:166 http://ftpmaster.internal/ubuntu questing/main armhf python3-werkzeug all 3.1.3-2 [169 kB] 229s Get:167 http://ftpmaster.internal/ubuntu questing/universe armhf python3-pytest-localserver all 0.9.0.post0-1 [21.9 kB] 229s Get:168 http://ftpmaster.internal/ubuntu questing/universe armhf python3-pytest-xdist all 3.6.1-1 [33.8 kB] 229s Get:169 http://ftpmaster.internal/ubuntu questing/universe armhf python3-pytestqt all 4.4.0-1 [32.4 kB] 229s Get:170 http://ftpmaster.internal/ubuntu questing/main armhf python3-greenlet armhf 3.1.0-1build1 [161 kB] 230s Get:171 http://ftpmaster.internal/ubuntu questing/main armhf python3-sqlalchemy all 2.0.38+ds1-0ubuntu2 [1215 kB] 230s Get:172 http://ftpmaster.internal/ubuntu questing/universe armhf python3-tables-lib armhf 3.10.2-2build1 [523 kB] 230s Get:173 http://ftpmaster.internal/ubuntu questing/universe armhf python3-tables all 3.10.2-2build1 [354 kB] 230s Get:174 http://ftpmaster.internal/ubuntu questing/main armhf python3-tabulate all 0.9.0-1 [45.3 kB] 230s Get:175 http://ftpmaster.internal/ubuntu questing/main armhf python3-tz all 2025.1-3 [1866 B] 230s Get:176 http://ftpmaster.internal/ubuntu questing/universe armhf python3-xarray all 2025.01.2-1 [810 kB] 230s Get:177 http://ftpmaster.internal/ubuntu questing/universe armhf python3-xlrd all 2.0.1-2 [83.1 kB] 230s Get:178 http://ftpmaster.internal/ubuntu questing/universe armhf python3-xlsxwriter all 3.1.9-2 [462 kB] 230s Get:179 http://ftpmaster.internal/ubuntu questing/universe armhf python3-zstandard armhf 0.23.0-3build1 [343 kB] 230s Get:180 http://ftpmaster.internal/ubuntu questing/main armhf tzdata-legacy all 2025b-1ubuntu1 [99.2 kB] 230s Get:181 http://ftpmaster.internal/ubuntu questing/main armhf x11-xkb-utils armhf 7.7+9 [159 kB] 230s Get:182 http://ftpmaster.internal/ubuntu questing/universe armhf xsel armhf 1.2.1-1 [19.1 kB] 230s Get:183 http://ftpmaster.internal/ubuntu questing/main armhf xserver-common all 2:21.1.16-1ubuntu1 [34.4 kB] 230s Get:184 http://ftpmaster.internal/ubuntu questing/main armhf libglx0 armhf 1.7.0-1build1 [39.3 kB] 230s Get:185 http://ftpmaster.internal/ubuntu questing/main armhf libgl1 armhf 1.7.0-1build1 [105 kB] 230s Get:186 http://ftpmaster.internal/ubuntu questing/universe armhf xvfb armhf 2:21.1.16-1ubuntu1 [732 kB] 230s Get:187 http://ftpmaster.internal/ubuntu questing/universe armhf locales-all armhf 2.41-6ubuntu1 [11.2 MB] 231s Fetched 138 MB in 8s (17.8 MB/s) 231s Selecting previously unselected package libtcl8.6:armhf. 231s (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 ... 67241 files and directories currently installed.) 231s Preparing to unpack .../000-libtcl8.6_8.6.16+dfsg-1_armhf.deb ... 231s Unpacking libtcl8.6:armhf (8.6.16+dfsg-1) ... 231s Selecting previously unselected package libfreetype6:armhf. 231s Preparing to unpack .../001-libfreetype6_2.13.3+dfsg-1_armhf.deb ... 231s Unpacking libfreetype6:armhf (2.13.3+dfsg-1) ... 231s Selecting previously unselected package fonts-dejavu-mono. 231s Preparing to unpack .../002-fonts-dejavu-mono_2.37-8_all.deb ... 231s Unpacking fonts-dejavu-mono (2.37-8) ... 232s Selecting previously unselected package fonts-dejavu-core. 232s Preparing to unpack .../003-fonts-dejavu-core_2.37-8_all.deb ... 232s Unpacking fonts-dejavu-core (2.37-8) ... 232s Selecting previously unselected package fontconfig-config. 232s Preparing to unpack .../004-fontconfig-config_2.15.0-2.2ubuntu1_armhf.deb ... 232s Unpacking fontconfig-config (2.15.0-2.2ubuntu1) ... 232s Selecting previously unselected package libfontconfig1:armhf. 232s Preparing to unpack .../005-libfontconfig1_2.15.0-2.2ubuntu1_armhf.deb ... 232s Unpacking libfontconfig1:armhf (2.15.0-2.2ubuntu1) ... 232s Selecting previously unselected package libxrender1:armhf. 232s Preparing to unpack .../006-libxrender1_1%3a0.9.12-1_armhf.deb ... 232s Unpacking libxrender1:armhf (1:0.9.12-1) ... 232s Selecting previously unselected package libxft2:armhf. 232s Preparing to unpack .../007-libxft2_2.3.6-1build1_armhf.deb ... 232s Unpacking libxft2:armhf (2.3.6-1build1) ... 232s Selecting previously unselected package x11-common. 232s Preparing to unpack .../008-x11-common_1%3a7.7+23ubuntu4_all.deb ... 232s Unpacking x11-common (1:7.7+23ubuntu4) ... 232s Selecting previously unselected package libxss1:armhf. 232s Preparing to unpack .../009-libxss1_1%3a1.2.3-1build3_armhf.deb ... 232s Unpacking libxss1:armhf (1:1.2.3-1build3) ... 232s Selecting previously unselected package libtk8.6:armhf. 232s Preparing to unpack .../010-libtk8.6_8.6.16-1_armhf.deb ... 232s Unpacking libtk8.6:armhf (8.6.16-1) ... 232s Selecting previously unselected package tk8.6-blt2.5. 232s Preparing to unpack .../011-tk8.6-blt2.5_2.5.3+dfsg-8_armhf.deb ... 232s Unpacking tk8.6-blt2.5 (2.5.3+dfsg-8) ... 232s Selecting previously unselected package blt. 232s Preparing to unpack .../012-blt_2.5.3+dfsg-8_armhf.deb ... 232s Unpacking blt (2.5.3+dfsg-8) ... 233s Selecting previously unselected package fontconfig. 233s Preparing to unpack .../013-fontconfig_2.15.0-2.2ubuntu1_armhf.deb ... 233s Unpacking fontconfig (2.15.0-2.2ubuntu1) ... 233s Selecting previously unselected package fonts-lyx. 233s Preparing to unpack .../014-fonts-lyx_2.4.3-1_all.deb ... 233s Unpacking fonts-lyx (2.4.3-1) ... 233s Selecting previously unselected package libaec0:armhf. 233s Preparing to unpack .../015-libaec0_1.1.3-1_armhf.deb ... 233s Unpacking libaec0:armhf (1.1.3-1) ... 233s Selecting previously unselected package libavahi-common-data:armhf. 233s Preparing to unpack .../016-libavahi-common-data_0.8-16ubuntu2_armhf.deb ... 233s Unpacking libavahi-common-data:armhf (0.8-16ubuntu2) ... 233s Selecting previously unselected package libavahi-common3:armhf. 233s Preparing to unpack .../017-libavahi-common3_0.8-16ubuntu2_armhf.deb ... 233s Unpacking libavahi-common3:armhf (0.8-16ubuntu2) ... 233s Selecting previously unselected package libavahi-client3:armhf. 233s Preparing to unpack .../018-libavahi-client3_0.8-16ubuntu2_armhf.deb ... 233s Unpacking libavahi-client3:armhf (0.8-16ubuntu2) ... 233s Selecting previously unselected package libsnappy1v5:armhf. 233s Preparing to unpack .../019-libsnappy1v5_1.2.2-1_armhf.deb ... 233s Unpacking libsnappy1v5:armhf (1.2.2-1) ... 233s Selecting previously unselected package libblosc1:armhf. 233s Preparing to unpack .../020-libblosc1_1.21.5+ds-1build1_armhf.deb ... 233s Unpacking libblosc1:armhf (1.21.5+ds-1build1) ... 233s Selecting previously unselected package libblosc2-4:armhf. 233s Preparing to unpack .../021-libblosc2-4_2.17.1+ds-1_armhf.deb ... 233s Unpacking libblosc2-4:armhf (2.17.1+ds-1) ... 233s Selecting previously unselected package libcups2t64:armhf. 233s Preparing to unpack .../022-libcups2t64_2.4.12-0ubuntu1_armhf.deb ... 233s Unpacking libcups2t64:armhf (2.4.12-0ubuntu1) ... 233s Selecting previously unselected package libdeflate0:armhf. 233s Preparing to unpack .../023-libdeflate0_1.23-2_armhf.deb ... 233s Unpacking libdeflate0:armhf (1.23-2) ... 233s Selecting previously unselected package libdouble-conversion3:armhf. 233s Preparing to unpack .../024-libdouble-conversion3_3.3.1-1_armhf.deb ... 233s Unpacking libdouble-conversion3:armhf (3.3.1-1) ... 233s Selecting previously unselected package libwayland-server0:armhf. 233s Preparing to unpack .../025-libwayland-server0_1.23.1-3_armhf.deb ... 233s Unpacking libwayland-server0:armhf (1.23.1-3) ... 233s Selecting previously unselected package libllvm19:armhf. 233s Preparing to unpack .../026-libllvm19_1%3a19.1.7-3ubuntu1_armhf.deb ... 233s Unpacking libllvm19:armhf (1:19.1.7-3ubuntu1) ... 235s Selecting previously unselected package libx11-xcb1:armhf. 235s Preparing to unpack .../027-libx11-xcb1_2%3a1.8.12-1_armhf.deb ... 235s Unpacking libx11-xcb1:armhf (2:1.8.12-1) ... 235s Selecting previously unselected package libxcb-dri3-0:armhf. 235s Preparing to unpack .../028-libxcb-dri3-0_1.17.0-2_armhf.deb ... 235s Unpacking libxcb-dri3-0:armhf (1.17.0-2) ... 235s Selecting previously unselected package libxcb-present0:armhf. 235s Preparing to unpack .../029-libxcb-present0_1.17.0-2_armhf.deb ... 235s Unpacking libxcb-present0:armhf (1.17.0-2) ... 235s Selecting previously unselected package libxcb-randr0:armhf. 235s Preparing to unpack .../030-libxcb-randr0_1.17.0-2_armhf.deb ... 235s Unpacking libxcb-randr0:armhf (1.17.0-2) ... 235s Selecting previously unselected package libxcb-sync1:armhf. 235s Preparing to unpack .../031-libxcb-sync1_1.17.0-2_armhf.deb ... 235s Unpacking libxcb-sync1:armhf (1.17.0-2) ... 235s Selecting previously unselected package libxcb-xfixes0:armhf. 235s Preparing to unpack .../032-libxcb-xfixes0_1.17.0-2_armhf.deb ... 235s Unpacking libxcb-xfixes0:armhf (1.17.0-2) ... 235s Selecting previously unselected package libxshmfence1:armhf. 235s Preparing to unpack .../033-libxshmfence1_1.3.3-1_armhf.deb ... 235s Unpacking libxshmfence1:armhf (1.3.3-1) ... 235s Selecting previously unselected package mesa-libgallium:armhf. 235s Preparing to unpack .../034-mesa-libgallium_25.0.3-1ubuntu2_armhf.deb ... 235s Unpacking mesa-libgallium:armhf (25.0.3-1ubuntu2) ... 235s Selecting previously unselected package libgbm1:armhf. 235s Preparing to unpack .../035-libgbm1_25.0.3-1ubuntu2_armhf.deb ... 235s Unpacking libgbm1:armhf (25.0.3-1ubuntu2) ... 235s Selecting previously unselected package libwayland-client0:armhf. 235s Preparing to unpack .../036-libwayland-client0_1.23.1-3_armhf.deb ... 235s Unpacking libwayland-client0:armhf (1.23.1-3) ... 235s Selecting previously unselected package libxcb-shm0:armhf. 235s Preparing to unpack .../037-libxcb-shm0_1.17.0-2_armhf.deb ... 235s Unpacking libxcb-shm0:armhf (1.17.0-2) ... 235s Selecting previously unselected package libegl-mesa0:armhf. 235s Preparing to unpack .../038-libegl-mesa0_25.0.3-1ubuntu2_armhf.deb ... 235s Unpacking libegl-mesa0:armhf (25.0.3-1ubuntu2) ... 235s Selecting previously unselected package libfontenc1:armhf. 235s Preparing to unpack .../039-libfontenc1_1%3a1.1.8-1build1_armhf.deb ... 235s Unpacking libfontenc1:armhf (1:1.1.8-1build1) ... 235s Selecting previously unselected package libvulkan1:armhf. 235s Preparing to unpack .../040-libvulkan1_1.4.309.0-1_armhf.deb ... 235s Unpacking libvulkan1:armhf (1.4.309.0-1) ... 235s Selecting previously unselected package libgl1-mesa-dri:armhf. 235s Preparing to unpack .../041-libgl1-mesa-dri_25.0.3-1ubuntu2_armhf.deb ... 235s Unpacking libgl1-mesa-dri:armhf (25.0.3-1ubuntu2) ... 235s Selecting previously unselected package libxcb-glx0:armhf. 235s Preparing to unpack .../042-libxcb-glx0_1.17.0-2_armhf.deb ... 235s Unpacking libxcb-glx0:armhf (1.17.0-2) ... 235s Selecting previously unselected package libxxf86vm1:armhf. 235s Preparing to unpack .../043-libxxf86vm1_1%3a1.1.4-1build4_armhf.deb ... 235s Unpacking libxxf86vm1:armhf (1:1.1.4-1build4) ... 235s Selecting previously unselected package libglx-mesa0:armhf. 236s Preparing to unpack .../044-libglx-mesa0_25.0.3-1ubuntu2_armhf.deb ... 236s Unpacking libglx-mesa0:armhf (25.0.3-1ubuntu2) ... 236s Selecting previously unselected package libgomp1:armhf. 236s Preparing to unpack .../045-libgomp1_15.1.0-2ubuntu1_armhf.deb ... 236s Unpacking libgomp1:armhf (15.1.0-2ubuntu1) ... 236s Selecting previously unselected package libgraphite2-3:armhf. 236s Preparing to unpack .../046-libgraphite2-3_1.3.14-2ubuntu1_armhf.deb ... 236s Unpacking libgraphite2-3:armhf (1.3.14-2ubuntu1) ... 236s Selecting previously unselected package libharfbuzz0b:armhf. 236s Preparing to unpack .../047-libharfbuzz0b_10.2.0-1_armhf.deb ... 236s Unpacking libharfbuzz0b:armhf (10.2.0-1) ... 236s Selecting previously unselected package libsz2:armhf. 236s Preparing to unpack .../048-libsz2_1.1.3-1_armhf.deb ... 236s Unpacking libsz2:armhf (1.1.3-1) ... 236s Selecting previously unselected package libhdf5-310:armhf. 236s Preparing to unpack .../049-libhdf5-310_1.14.5+repack-3_armhf.deb ... 236s Unpacking libhdf5-310:armhf (1.14.5+repack-3) ... 236s Selecting previously unselected package libice6:armhf. 236s Preparing to unpack .../050-libice6_2%3a1.1.1-1_armhf.deb ... 236s Unpacking libice6:armhf (2:1.1.1-1) ... 236s Selecting previously unselected package libimagequant0:armhf. 236s Preparing to unpack .../051-libimagequant0_2.18.0-1build1_armhf.deb ... 236s Unpacking libimagequant0:armhf (2.18.0-1build1) ... 236s Selecting previously unselected package libwacom-common. 236s Preparing to unpack .../052-libwacom-common_2.14.0-1_all.deb ... 236s Unpacking libwacom-common (2.14.0-1) ... 236s Selecting previously unselected package libwacom9:armhf. 236s Preparing to unpack .../053-libwacom9_2.14.0-1_armhf.deb ... 236s Unpacking libwacom9:armhf (2.14.0-1) ... 236s Selecting previously unselected package libinput-bin. 236s Preparing to unpack .../054-libinput-bin_1.28.1-1_armhf.deb ... 236s Unpacking libinput-bin (1.28.1-1) ... 236s Selecting previously unselected package libmtdev1t64:armhf. 236s Preparing to unpack .../055-libmtdev1t64_1.1.7-1_armhf.deb ... 236s Unpacking libmtdev1t64:armhf (1.1.7-1) ... 236s Selecting previously unselected package libinput10:armhf. 236s Preparing to unpack .../056-libinput10_1.28.1-1_armhf.deb ... 236s Unpacking libinput10:armhf (1.28.1-1) ... 236s Selecting previously unselected package libjpeg-turbo8:armhf. 236s Preparing to unpack .../057-libjpeg-turbo8_2.1.5-3ubuntu2_armhf.deb ... 236s Unpacking libjpeg-turbo8:armhf (2.1.5-3ubuntu2) ... 236s Selecting previously unselected package libjpeg8:armhf. 236s Preparing to unpack .../058-libjpeg8_8c-2ubuntu11_armhf.deb ... 236s Unpacking libjpeg8:armhf (8c-2ubuntu11) ... 236s Selecting previously unselected package libjs-jquery. 236s Preparing to unpack .../059-libjs-jquery_3.6.1+dfsg+~3.5.14-1_all.deb ... 236s Unpacking libjs-jquery (3.6.1+dfsg+~3.5.14-1) ... 236s Selecting previously unselected package libjs-jquery-ui. 236s Preparing to unpack .../060-libjs-jquery-ui_1.13.2+dfsg-1_all.deb ... 236s Unpacking libjs-jquery-ui (1.13.2+dfsg-1) ... 237s Selecting previously unselected package liblbfgsb0:armhf. 237s Preparing to unpack .../061-liblbfgsb0_3.0+dfsg.4-1build1_armhf.deb ... 237s Unpacking liblbfgsb0:armhf (3.0+dfsg.4-1build1) ... 237s Selecting previously unselected package liblcms2-2:armhf. 237s Preparing to unpack .../062-liblcms2-2_2.16-2_armhf.deb ... 237s Unpacking liblcms2-2:armhf (2.16-2) ... 237s Selecting previously unselected package liblerc4:armhf. 237s Preparing to unpack .../063-liblerc4_4.0.0+ds-5ubuntu1_armhf.deb ... 237s Unpacking liblerc4:armhf (4.0.0+ds-5ubuntu1) ... 237s Selecting previously unselected package libmd4c0:armhf. 237s Preparing to unpack .../064-libmd4c0_0.5.2-2_armhf.deb ... 237s Unpacking libmd4c0:armhf (0.5.2-2) ... 237s Selecting previously unselected package libpcre2-16-0:armhf. 237s Preparing to unpack .../065-libpcre2-16-0_10.45-1_armhf.deb ... 237s Unpacking libpcre2-16-0:armhf (10.45-1) ... 237s Selecting previously unselected package libpixman-1-0:armhf. 237s Preparing to unpack .../066-libpixman-1-0_0.44.0-3_armhf.deb ... 237s Unpacking libpixman-1-0:armhf (0.44.0-3) ... 237s Selecting previously unselected package libpython3.13:armhf. 237s Preparing to unpack .../067-libpython3.13_3.13.3-1_armhf.deb ... 237s Unpacking libpython3.13:armhf (3.13.3-1) ... 237s Selecting previously unselected package libqhull-r8.0:armhf. 237s Preparing to unpack .../068-libqhull-r8.0_2020.2-6build1_armhf.deb ... 237s Unpacking libqhull-r8.0:armhf (2020.2-6build1) ... 237s Selecting previously unselected package libqt5core5t64:armhf. 237s Preparing to unpack .../069-libqt5core5t64_5.15.15+dfsg-4ubuntu1_armhf.deb ... 237s Unpacking libqt5core5t64:armhf (5.15.15+dfsg-4ubuntu1) ... 237s Selecting previously unselected package libqt5dbus5t64:armhf. 237s Preparing to unpack .../070-libqt5dbus5t64_5.15.15+dfsg-4ubuntu1_armhf.deb ... 237s Unpacking libqt5dbus5t64:armhf (5.15.15+dfsg-4ubuntu1) ... 237s Selecting previously unselected package libglvnd0:armhf. 237s Preparing to unpack .../071-libglvnd0_1.7.0-1build1_armhf.deb ... 237s Unpacking libglvnd0:armhf (1.7.0-1build1) ... 237s Selecting previously unselected package libegl1:armhf. 237s Preparing to unpack .../072-libegl1_1.7.0-1build1_armhf.deb ... 237s Unpacking libegl1:armhf (1.7.0-1build1) ... 237s Selecting previously unselected package libgles2:armhf. 237s Preparing to unpack .../073-libgles2_1.7.0-1build1_armhf.deb ... 237s Unpacking libgles2:armhf (1.7.0-1build1) ... 237s Selecting previously unselected package libqt5network5t64:armhf. 237s Preparing to unpack .../074-libqt5network5t64_5.15.15+dfsg-4ubuntu1_armhf.deb ... 237s Unpacking libqt5network5t64:armhf (5.15.15+dfsg-4ubuntu1) ... 238s Selecting previously unselected package libsm6:armhf. 238s Preparing to unpack .../075-libsm6_2%3a1.2.6-1_armhf.deb ... 238s Unpacking libsm6:armhf (2:1.2.6-1) ... 238s Selecting previously unselected package libxcb-icccm4:armhf. 238s Preparing to unpack .../076-libxcb-icccm4_0.4.2-1_armhf.deb ... 238s Unpacking libxcb-icccm4:armhf (0.4.2-1) ... 238s Selecting previously unselected package libxcb-util1:armhf. 238s Preparing to unpack .../077-libxcb-util1_0.4.1-1_armhf.deb ... 238s Unpacking libxcb-util1:armhf (0.4.1-1) ... 238s Selecting previously unselected package libxcb-image0:armhf. 238s Preparing to unpack .../078-libxcb-image0_0.4.0-2build1_armhf.deb ... 238s Unpacking libxcb-image0:armhf (0.4.0-2build1) ... 238s Selecting previously unselected package libxcb-keysyms1:armhf. 238s Preparing to unpack .../079-libxcb-keysyms1_0.4.1-1_armhf.deb ... 238s Unpacking libxcb-keysyms1:armhf (0.4.1-1) ... 238s Selecting previously unselected package libxcb-render0:armhf. 238s Preparing to unpack .../080-libxcb-render0_1.17.0-2_armhf.deb ... 238s Unpacking libxcb-render0:armhf (1.17.0-2) ... 238s Selecting previously unselected package libxcb-render-util0:armhf. 238s Preparing to unpack .../081-libxcb-render-util0_0.3.10-1_armhf.deb ... 238s Unpacking libxcb-render-util0:armhf (0.3.10-1) ... 238s Selecting previously unselected package libxcb-shape0:armhf. 238s Preparing to unpack .../082-libxcb-shape0_1.17.0-2_armhf.deb ... 238s Unpacking libxcb-shape0:armhf (1.17.0-2) ... 238s Selecting previously unselected package libxcb-xinerama0:armhf. 238s Preparing to unpack .../083-libxcb-xinerama0_1.17.0-2_armhf.deb ... 238s Unpacking libxcb-xinerama0:armhf (1.17.0-2) ... 238s Selecting previously unselected package libxcb-xinput0:armhf. 238s Preparing to unpack .../084-libxcb-xinput0_1.17.0-2_armhf.deb ... 238s Unpacking libxcb-xinput0:armhf (1.17.0-2) ... 238s Selecting previously unselected package libxcb-xkb1:armhf. 238s Preparing to unpack .../085-libxcb-xkb1_1.17.0-2_armhf.deb ... 238s Unpacking libxcb-xkb1:armhf (1.17.0-2) ... 238s Selecting previously unselected package libxkbcommon-x11-0:armhf. 238s Preparing to unpack .../086-libxkbcommon-x11-0_1.7.0-2_armhf.deb ... 238s Unpacking libxkbcommon-x11-0:armhf (1.7.0-2) ... 238s Selecting previously unselected package libqt5gui5t64:armhf. 238s Preparing to unpack .../087-libqt5gui5t64_5.15.15+dfsg-4ubuntu1_armhf.deb ... 238s Unpacking libqt5gui5t64:armhf (5.15.15+dfsg-4ubuntu1) ... 238s Selecting previously unselected package libqt5widgets5t64:armhf. 238s Preparing to unpack .../088-libqt5widgets5t64_5.15.15+dfsg-4ubuntu1_armhf.deb ... 238s Unpacking libqt5widgets5t64:armhf (5.15.15+dfsg-4ubuntu1) ... 238s Selecting previously unselected package libqt5xml5t64:armhf. 238s Preparing to unpack .../089-libqt5xml5t64_5.15.15+dfsg-4ubuntu1_armhf.deb ... 238s Unpacking libqt5xml5t64:armhf (5.15.15+dfsg-4ubuntu1) ... 238s Selecting previously unselected package libqt5designer5:armhf. 239s Preparing to unpack .../090-libqt5designer5_5.15.15-6build1_armhf.deb ... 239s Unpacking libqt5designer5:armhf (5.15.15-6build1) ... 239s Selecting previously unselected package libqt5sql5t64:armhf. 239s Preparing to unpack .../091-libqt5sql5t64_5.15.15+dfsg-4ubuntu1_armhf.deb ... 239s Unpacking libqt5sql5t64:armhf (5.15.15+dfsg-4ubuntu1) ... 239s Selecting previously unselected package libqt5help5:armhf. 239s Preparing to unpack .../092-libqt5help5_5.15.15-6build1_armhf.deb ... 239s Unpacking libqt5help5:armhf (5.15.15-6build1) ... 239s Selecting previously unselected package libqt5printsupport5t64:armhf. 239s Preparing to unpack .../093-libqt5printsupport5t64_5.15.15+dfsg-4ubuntu1_armhf.deb ... 239s Unpacking libqt5printsupport5t64:armhf (5.15.15+dfsg-4ubuntu1) ... 239s Selecting previously unselected package libqt5test5t64:armhf. 239s Preparing to unpack .../094-libqt5test5t64_5.15.15+dfsg-4ubuntu1_armhf.deb ... 239s Unpacking libqt5test5t64:armhf (5.15.15+dfsg-4ubuntu1) ... 239s Selecting previously unselected package libraqm0:armhf. 239s Preparing to unpack .../095-libraqm0_0.10.2-1_armhf.deb ... 239s Unpacking libraqm0:armhf (0.10.2-1) ... 239s Selecting previously unselected package libsharpyuv0:armhf. 239s Preparing to unpack .../096-libsharpyuv0_1.5.0-0.1_armhf.deb ... 239s Unpacking libsharpyuv0:armhf (1.5.0-0.1) ... 239s Selecting previously unselected package libjbig0:armhf. 239s Preparing to unpack .../097-libjbig0_2.1-6.1ubuntu2_armhf.deb ... 239s Unpacking libjbig0:armhf (2.1-6.1ubuntu2) ... 239s Selecting previously unselected package libwebp7:armhf. 239s Preparing to unpack .../098-libwebp7_1.5.0-0.1_armhf.deb ... 239s Unpacking libwebp7:armhf (1.5.0-0.1) ... 239s Selecting previously unselected package libtiff6:armhf. 239s Preparing to unpack .../099-libtiff6_4.7.0-3ubuntu1_armhf.deb ... 239s Unpacking libtiff6:armhf (4.7.0-3ubuntu1) ... 239s Selecting previously unselected package libwebpdemux2:armhf. 239s Preparing to unpack .../100-libwebpdemux2_1.5.0-0.1_armhf.deb ... 239s Unpacking libwebpdemux2:armhf (1.5.0-0.1) ... 239s Selecting previously unselected package libwebpmux3:armhf. 239s Preparing to unpack .../101-libwebpmux3_1.5.0-0.1_armhf.deb ... 239s Unpacking libwebpmux3:armhf (1.5.0-0.1) ... 239s Selecting previously unselected package libxt6t64:armhf. 240s Preparing to unpack .../102-libxt6t64_1%3a1.2.1-1.2build1_armhf.deb ... 240s Unpacking libxt6t64:armhf (1:1.2.1-1.2build1) ... 240s Selecting previously unselected package libxmu6:armhf. 240s Preparing to unpack .../103-libxmu6_2%3a1.1.3-3build2_armhf.deb ... 240s Unpacking libxmu6:armhf (2:1.1.3-3build2) ... 240s Selecting previously unselected package libxpm4:armhf. 240s Preparing to unpack .../104-libxpm4_1%3a3.5.17-1build2_armhf.deb ... 240s Unpacking libxpm4:armhf (1:3.5.17-1build2) ... 240s Selecting previously unselected package libxaw7:armhf. 240s Preparing to unpack .../105-libxaw7_2%3a1.0.16-1_armhf.deb ... 240s Unpacking libxaw7:armhf (2:1.0.16-1) ... 240s Selecting previously unselected package libxfont2:armhf. 240s Preparing to unpack .../106-libxfont2_1%3a2.0.6-1build1_armhf.deb ... 240s Unpacking libxfont2:armhf (1:2.0.6-1build1) ... 240s Selecting previously unselected package libxkbfile1:armhf. 240s Preparing to unpack .../107-libxkbfile1_1%3a1.1.0-1build4_armhf.deb ... 240s Unpacking libxkbfile1:armhf (1:1.1.0-1build4) ... 240s Selecting previously unselected package libxrandr2:armhf. 240s Preparing to unpack .../108-libxrandr2_2%3a1.5.4-1_armhf.deb ... 240s Unpacking libxrandr2:armhf (2:1.5.4-1) ... 240s Selecting previously unselected package libxslt1.1:armhf. 240s Preparing to unpack .../109-libxslt1.1_1.1.39-0exp1ubuntu4_armhf.deb ... 240s Unpacking libxslt1.1:armhf (1.1.39-0exp1ubuntu4) ... 240s Selecting previously unselected package python-matplotlib-data. 240s Preparing to unpack .../110-python-matplotlib-data_3.10.1+dfsg1-3_all.deb ... 240s Unpacking python-matplotlib-data (3.10.1+dfsg1-3) ... 240s Selecting previously unselected package python-tables-data. 240s Preparing to unpack .../111-python-tables-data_3.10.2-2build1_all.deb ... 240s Unpacking python-tables-data (3.10.2-2build1) ... 240s Selecting previously unselected package python3-all. 240s Preparing to unpack .../112-python3-all_3.13.3-1_armhf.deb ... 240s Unpacking python3-all (3.13.3-1) ... 240s Selecting previously unselected package python3-async-generator. 240s Preparing to unpack .../113-python3-async-generator_1.10-4_all.deb ... 240s Unpacking python3-async-generator (1.10-4) ... 240s Selecting previously unselected package python3-bottleneck. 240s Preparing to unpack .../114-python3-bottleneck_1.4.2+ds1-2build1_armhf.deb ... 240s Unpacking python3-bottleneck (1.4.2+ds1-2build1) ... 240s Selecting previously unselected package python3-brotli. 240s Preparing to unpack .../115-python3-brotli_1.1.0-2build4_armhf.deb ... 240s Unpacking python3-brotli (1.1.0-2build4) ... 240s Selecting previously unselected package python3-soupsieve. 240s Preparing to unpack .../116-python3-soupsieve_2.7-1_all.deb ... 240s Unpacking python3-soupsieve (2.7-1) ... 240s Selecting previously unselected package python3-bs4. 240s Preparing to unpack .../117-python3-bs4_4.13.4-1_all.deb ... 240s Unpacking python3-bs4 (4.13.4-1) ... 240s Selecting previously unselected package python3-click. 240s Preparing to unpack .../118-python3-click_8.2.0+0.really.8.1.8-1_all.deb ... 240s Unpacking python3-click (8.2.0+0.really.8.1.8-1) ... 240s Selecting previously unselected package python3-cloudpickle. 240s Preparing to unpack .../119-python3-cloudpickle_3.1.1-1_all.deb ... 240s Unpacking python3-cloudpickle (3.1.1-1) ... 240s Selecting previously unselected package python3-contourpy. 240s Preparing to unpack .../120-python3-contourpy_1.3.1-1build1_armhf.deb ... 240s Unpacking python3-contourpy (1.3.1-1build1) ... 240s Selecting previously unselected package python3-cpuinfo. 240s Preparing to unpack .../121-python3-cpuinfo_9.0.0+git20221119-3_all.deb ... 240s Unpacking python3-cpuinfo (9.0.0+git20221119-3) ... 240s Selecting previously unselected package python3-cycler. 240s Preparing to unpack .../122-python3-cycler_0.12.1-1_all.deb ... 240s Unpacking python3-cycler (0.12.1-1) ... 240s Selecting previously unselected package python3-fsspec. 240s Preparing to unpack .../123-python3-fsspec_2025.3.0-1_all.deb ... 240s Unpacking python3-fsspec (2025.3.0-1) ... 240s Selecting previously unselected package python3-toolz. 240s Preparing to unpack .../124-python3-toolz_1.0.0-2_all.deb ... 240s Unpacking python3-toolz (1.0.0-2) ... 240s Selecting previously unselected package python3-locket. 241s Preparing to unpack .../125-python3-locket_1.0.0-2_all.deb ... 241s Unpacking python3-locket (1.0.0-2) ... 241s Selecting previously unselected package python3-partd. 241s Preparing to unpack .../126-python3-partd_1.4.2-1_all.deb ... 241s Unpacking python3-partd (1.4.2-1) ... 241s Selecting previously unselected package python3-dask. 241s Preparing to unpack .../127-python3-dask_2024.12.1+dfsg-2_all.deb ... 241s Unpacking python3-dask (2024.12.1+dfsg-2) ... 241s Selecting previously unselected package python3-decorator. 241s Preparing to unpack .../128-python3-decorator_5.2.1-2_all.deb ... 241s Unpacking python3-decorator (5.2.1-2) ... 241s Selecting previously unselected package python3-defusedxml. 241s Preparing to unpack .../129-python3-defusedxml_0.7.1-3_all.deb ... 241s Unpacking python3-defusedxml (0.7.1-3) ... 241s Selecting previously unselected package python3-et-xmlfile. 241s Preparing to unpack .../130-python3-et-xmlfile_2.0.0-1_all.deb ... 241s Unpacking python3-et-xmlfile (2.0.0-1) ... 241s Selecting previously unselected package python3-execnet. 241s Preparing to unpack .../131-python3-execnet_2.1.1-1_all.deb ... 241s Unpacking python3-execnet (2.1.1-1) ... 241s Selecting previously unselected package python3-platformdirs. 241s Preparing to unpack .../132-python3-platformdirs_4.3.7-1_all.deb ... 241s Unpacking python3-platformdirs (4.3.7-1) ... 241s Selecting previously unselected package python3-fs. 241s Preparing to unpack .../133-python3-fs_2.4.16-7_all.deb ... 241s Unpacking python3-fs (2.4.16-7) ... 241s Selecting previously unselected package python3-lxml:armhf. 241s Preparing to unpack .../134-python3-lxml_5.4.0-1_armhf.deb ... 241s Unpacking python3-lxml:armhf (5.4.0-1) ... 241s Selecting previously unselected package python3-lz4. 241s Preparing to unpack .../135-python3-lz4_4.4.0+dfsg-2_armhf.deb ... 241s Unpacking python3-lz4 (4.4.0+dfsg-2) ... 241s Selecting previously unselected package python3-scipy. 241s Preparing to unpack .../136-python3-scipy_1.14.1-4ubuntu2_armhf.deb ... 241s Unpacking python3-scipy (1.14.1-4ubuntu2) ... 242s Selecting previously unselected package python3-mpmath. 242s Preparing to unpack .../137-python3-mpmath_1.3.0-1_all.deb ... 242s Unpacking python3-mpmath (1.3.0-1) ... 242s Selecting previously unselected package python3-sympy. 242s Preparing to unpack .../138-python3-sympy_1.13.3-5_all.deb ... 242s Unpacking python3-sympy (1.13.3-5) ... 242s Selecting previously unselected package python3-ufolib2. 243s Preparing to unpack .../139-python3-ufolib2_0.17.1+dfsg1-1_all.deb ... 243s Unpacking python3-ufolib2 (0.17.1+dfsg1-1) ... 243s Selecting previously unselected package unicode-data. 243s Preparing to unpack .../140-unicode-data_15.1.0-1_all.deb ... 243s Unpacking unicode-data (15.1.0-1) ... 243s Selecting previously unselected package python3-fonttools. 243s Preparing to unpack .../141-python3-fonttools_4.55.3-2build1_armhf.deb ... 243s Unpacking python3-fonttools (4.55.3-2build1) ... 243s Selecting previously unselected package python3-webencodings. 243s Preparing to unpack .../142-python3-webencodings_0.5.1-5_all.deb ... 243s Unpacking python3-webencodings (0.5.1-5) ... 243s Selecting previously unselected package python3-html5lib. 243s Preparing to unpack .../143-python3-html5lib_1.2-2_all.deb ... 243s Unpacking python3-html5lib (1.2-2) ... 243s Selecting previously unselected package python3-sortedcontainers. 243s Preparing to unpack .../144-python3-sortedcontainers_2.4.0-2_all.deb ... 243s Unpacking python3-sortedcontainers (2.4.0-2) ... 243s Selecting previously unselected package python3-hypothesis. 243s Preparing to unpack .../145-python3-hypothesis_6.127.4-1_all.deb ... 243s Unpacking python3-hypothesis (6.127.4-1) ... 243s Selecting previously unselected package python3-iniconfig. 243s Preparing to unpack .../146-python3-iniconfig_1.1.1-2_all.deb ... 243s Unpacking python3-iniconfig (1.1.1-2) ... 243s Selecting previously unselected package python3-kiwisolver. 243s Preparing to unpack .../147-python3-kiwisolver_1.4.7-3build1_armhf.deb ... 243s Unpacking python3-kiwisolver (1.4.7-3build1) ... 243s Selecting previously unselected package libopenjp2-7:armhf. 243s Preparing to unpack .../148-libopenjp2-7_2.5.3-2_armhf.deb ... 243s Unpacking libopenjp2-7:armhf (2.5.3-2) ... 243s Selecting previously unselected package python3-pil:armhf. 243s Preparing to unpack .../149-python3-pil_11.1.0-5build1_armhf.deb ... 243s Unpacking python3-pil:armhf (11.1.0-5build1) ... 244s Selecting previously unselected package python3.13-tk. 244s Preparing to unpack .../150-python3.13-tk_3.13.3-1_armhf.deb ... 244s Unpacking python3.13-tk (3.13.3-1) ... 244s Selecting previously unselected package python3-tk:armhf. 244s Preparing to unpack .../151-python3-tk_3.13.3-1_armhf.deb ... 244s Unpacking python3-tk:armhf (3.13.3-1) ... 244s Selecting previously unselected package python3-pil.imagetk:armhf. 244s Preparing to unpack .../152-python3-pil.imagetk_11.1.0-5build1_armhf.deb ... 244s Unpacking python3-pil.imagetk:armhf (11.1.0-5build1) ... 244s Selecting previously unselected package python3-matplotlib. 244s Preparing to unpack .../153-python3-matplotlib_3.10.1+dfsg1-3_armhf.deb ... 244s Unpacking python3-matplotlib (3.10.1+dfsg1-3) ... 245s Selecting previously unselected package python3-numexpr. 245s Preparing to unpack .../154-python3-numexpr_2.10.2-1build2_armhf.deb ... 245s Unpacking python3-numexpr (2.10.2-1build2) ... 245s Selecting previously unselected package python3-odf. 245s Preparing to unpack .../155-python3-odf_1.4.2-4_all.deb ... 245s Unpacking python3-odf (1.4.2-4) ... 245s Selecting previously unselected package python3-openpyxl. 245s Preparing to unpack .../156-python3-openpyxl_3.1.5+dfsg-2_all.deb ... 245s Unpacking python3-openpyxl (3.1.5+dfsg-2) ... 245s Selecting previously unselected package python3-pluggy. 245s Preparing to unpack .../157-python3-pluggy_1.5.0-1_all.deb ... 245s Unpacking python3-pluggy (1.5.0-1) ... 245s Selecting previously unselected package python3-py. 245s Preparing to unpack .../158-python3-py_1.11.0-4_all.deb ... 245s Unpacking python3-py (1.11.0-4) ... 245s Selecting previously unselected package python3-pyqt5.sip. 245s Preparing to unpack .../159-python3-pyqt5.sip_12.17.0-1build1_armhf.deb ... 245s Unpacking python3-pyqt5.sip (12.17.0-1build1) ... 245s Selecting previously unselected package python3-pyqt5. 245s Preparing to unpack .../160-python3-pyqt5_5.15.11+dfsg-2_armhf.deb ... 245s Unpacking python3-pyqt5 (5.15.11+dfsg-2) ... 245s Selecting previously unselected package python3-pyreadstat. 245s Preparing to unpack .../161-python3-pyreadstat_1.2.8-1build1_armhf.deb ... 245s Unpacking python3-pyreadstat (1.2.8-1build1) ... 245s Selecting previously unselected package python3-pytest. 245s Preparing to unpack .../162-python3-pytest_8.3.5-1_all.deb ... 245s Unpacking python3-pytest (8.3.5-1) ... 245s Selecting previously unselected package python3-pytest-asyncio. 245s Preparing to unpack .../163-python3-pytest-asyncio_0.25.1-1_all.deb ... 245s Unpacking python3-pytest-asyncio (0.25.1-1) ... 245s Selecting previously unselected package python3-pytest-forked. 245s Preparing to unpack .../164-python3-pytest-forked_1.6.0-3_all.deb ... 245s Unpacking python3-pytest-forked (1.6.0-3) ... 245s Selecting previously unselected package python3-werkzeug. 246s Preparing to unpack .../165-python3-werkzeug_3.1.3-2_all.deb ... 246s Unpacking python3-werkzeug (3.1.3-2) ... 246s Selecting previously unselected package python3-pytest-localserver. 246s Preparing to unpack .../166-python3-pytest-localserver_0.9.0.post0-1_all.deb ... 246s Unpacking python3-pytest-localserver (0.9.0.post0-1) ... 246s Selecting previously unselected package python3-pytest-xdist. 246s Preparing to unpack .../167-python3-pytest-xdist_3.6.1-1_all.deb ... 246s Unpacking python3-pytest-xdist (3.6.1-1) ... 246s Selecting previously unselected package python3-pytestqt. 246s Preparing to unpack .../168-python3-pytestqt_4.4.0-1_all.deb ... 246s Unpacking python3-pytestqt (4.4.0-1) ... 246s Selecting previously unselected package python3-greenlet. 246s Preparing to unpack .../169-python3-greenlet_3.1.0-1build1_armhf.deb ... 246s Unpacking python3-greenlet (3.1.0-1build1) ... 246s Selecting previously unselected package python3-sqlalchemy. 246s Preparing to unpack .../170-python3-sqlalchemy_2.0.38+ds1-0ubuntu2_all.deb ... 246s Unpacking python3-sqlalchemy (2.0.38+ds1-0ubuntu2) ... 246s Selecting previously unselected package python3-tables-lib. 246s Preparing to unpack .../171-python3-tables-lib_3.10.2-2build1_armhf.deb ... 246s Unpacking python3-tables-lib (3.10.2-2build1) ... 246s Selecting previously unselected package python3-tables. 246s Preparing to unpack .../172-python3-tables_3.10.2-2build1_all.deb ... 246s Unpacking python3-tables (3.10.2-2build1) ... 246s Selecting previously unselected package python3-tabulate. 246s Preparing to unpack .../173-python3-tabulate_0.9.0-1_all.deb ... 246s Unpacking python3-tabulate (0.9.0-1) ... 246s Selecting previously unselected package python3-tz. 246s Preparing to unpack .../174-python3-tz_2025.1-3_all.deb ... 246s Unpacking python3-tz (2025.1-3) ... 246s Selecting previously unselected package python3-xarray. 246s Preparing to unpack .../175-python3-xarray_2025.01.2-1_all.deb ... 246s Unpacking python3-xarray (2025.01.2-1) ... 246s Selecting previously unselected package python3-xlrd. 246s Preparing to unpack .../176-python3-xlrd_2.0.1-2_all.deb ... 246s Unpacking python3-xlrd (2.0.1-2) ... 246s Selecting previously unselected package python3-xlsxwriter. 246s Preparing to unpack .../177-python3-xlsxwriter_3.1.9-2_all.deb ... 246s Unpacking python3-xlsxwriter (3.1.9-2) ... 247s Selecting previously unselected package python3-zstandard. 247s Preparing to unpack .../178-python3-zstandard_0.23.0-3build1_armhf.deb ... 247s Unpacking python3-zstandard (0.23.0-3build1) ... 247s Selecting previously unselected package tzdata-legacy. 247s Preparing to unpack .../179-tzdata-legacy_2025b-1ubuntu1_all.deb ... 247s Unpacking tzdata-legacy (2025b-1ubuntu1) ... 247s Selecting previously unselected package x11-xkb-utils. 247s Preparing to unpack .../180-x11-xkb-utils_7.7+9_armhf.deb ... 247s Unpacking x11-xkb-utils (7.7+9) ... 247s Selecting previously unselected package xsel. 247s Preparing to unpack .../181-xsel_1.2.1-1_armhf.deb ... 247s Unpacking xsel (1.2.1-1) ... 247s Selecting previously unselected package xserver-common. 247s Preparing to unpack .../182-xserver-common_2%3a21.1.16-1ubuntu1_all.deb ... 247s Unpacking xserver-common (2:21.1.16-1ubuntu1) ... 247s Selecting previously unselected package libglx0:armhf. 247s Preparing to unpack .../183-libglx0_1.7.0-1build1_armhf.deb ... 247s Unpacking libglx0:armhf (1.7.0-1build1) ... 247s Selecting previously unselected package libgl1:armhf. 247s Preparing to unpack .../184-libgl1_1.7.0-1build1_armhf.deb ... 247s Unpacking libgl1:armhf (1.7.0-1build1) ... 247s Selecting previously unselected package xvfb. 247s Preparing to unpack .../185-xvfb_2%3a21.1.16-1ubuntu1_armhf.deb ... 247s Unpacking xvfb (2:21.1.16-1ubuntu1) ... 247s Selecting previously unselected package locales-all. 247s Preparing to unpack .../186-locales-all_2.41-6ubuntu1_armhf.deb ... 247s Unpacking locales-all (2.41-6ubuntu1) ... 249s Setting up libpython3.13:armhf (3.13.3-1) ... 249s Setting up libgraphite2-3:armhf (1.3.14-2ubuntu1) ... 249s Setting up xsel (1.2.1-1) ... 249s Setting up libxcb-dri3-0:armhf (1.17.0-2) ... 249s Setting up liblcms2-2:armhf (2.16-2) ... 249s Setting up python3-iniconfig (1.1.1-2) ... 250s Setting up libpixman-1-0:armhf (0.44.0-3) ... 250s Setting up libllvm19:armhf (1:19.1.7-3ubuntu1) ... 250s Setting up libsharpyuv0:armhf (1.5.0-0.1) ... 250s Setting up libwayland-server0:armhf (1.23.1-3) ... 250s Setting up libx11-xcb1:armhf (2:1.8.12-1) ... 250s Setting up libdouble-conversion3:armhf (3.3.1-1) ... 250s Setting up libxcb-xfixes0:armhf (1.17.0-2) ... 250s Setting up liblerc4:armhf (4.0.0+ds-5ubuntu1) ... 250s Setting up libxpm4:armhf (1:3.5.17-1build2) ... 250s Setting up python3-async-generator (1.10-4) ... 250s Setting up libxcb-xinput0:armhf (1.17.0-2) ... 250s Setting up libxrender1:armhf (1:0.9.12-1) ... 250s Setting up python3-py (1.11.0-4) ... 250s Setting up python3-lz4 (4.4.0+dfsg-2) ... 250s Setting up libxcb-render0:armhf (1.17.0-2) ... 250s Setting up python3-defusedxml (0.7.1-3) ... 250s Setting up libglvnd0:armhf (1.7.0-1build1) ... 250s Setting up fonts-lyx (2.4.3-1) ... 250s Setting up libxcb-glx0:armhf (1.17.0-2) ... 250s Setting up python3-fsspec (2025.3.0-1) ... 251s Setting up python3-xarray (2025.01.2-1) ... 253s Setting up libxcb-keysyms1:armhf (0.4.1-1) ... 253s Setting up libxcb-shape0:armhf (1.17.0-2) ... 253s Setting up x11-common (1:7.7+23ubuntu4) ... 253s Setting up libdeflate0:armhf (1.23-2) ... 253s Setting up python3-tabulate (0.9.0-1) ... 254s Setting up libqhull-r8.0:armhf (2020.2-6build1) ... 254s Setting up libxcb-render-util0:armhf (0.3.10-1) ... 254s Setting up python3-all (3.13.3-1) ... 254s Setting up libxcb-shm0:armhf (1.17.0-2) ... 254s Setting up libxcb-icccm4:armhf (0.4.2-1) ... 254s Setting up python3-sortedcontainers (2.4.0-2) ... 254s Setting up libgomp1:armhf (15.1.0-2ubuntu1) ... 254s Setting up python3-click (8.2.0+0.really.8.1.8-1) ... 254s Setting up libjbig0:armhf (2.1-6.1ubuntu2) ... 254s Setting up python3-webencodings (0.5.1-5) ... 254s Setting up python3-pyreadstat (1.2.8-1build1) ... 254s Setting up locales-all (2.41-6ubuntu1) ... 254s Setting up libpcre2-16-0:armhf (10.45-1) ... 254s Setting up libaec0:armhf (1.1.3-1) ... 254s Setting up python3-platformdirs (4.3.7-1) ... 255s Setting up tzdata-legacy (2025b-1ubuntu1) ... 255s Setting up python3-tz (2025.1-3) ... 255s Setting up libxcb-util1:armhf (0.4.1-1) ... 255s Setting up libxxf86vm1:armhf (1:1.1.4-1build4) ... 255s Setting up python3-cloudpickle (3.1.1-1) ... 255s Setting up libsnappy1v5:armhf (1.2.2-1) ... 255s Setting up libxcb-xkb1:armhf (1.17.0-2) ... 255s Setting up libxcb-image0:armhf (0.4.0-2build1) ... 255s Setting up python3-fs (2.4.16-7) ... 255s Setting up libxcb-present0:armhf (1.17.0-2) ... 255s Setting up unicode-data (15.1.0-1) ... 255s Setting up libqt5core5t64:armhf (5.15.15+dfsg-4ubuntu1) ... 255s Setting up python3-decorator (5.2.1-2) ... 255s Setting up libblosc2-4:armhf (2.17.1+ds-1) ... 255s Setting up libfontenc1:armhf (1:1.1.8-1build1) ... 255s Setting up python3-zstandard (0.23.0-3build1) ... 256s Setting up libxcb-xinerama0:armhf (1.17.0-2) ... 256s Setting up python3-xlsxwriter (3.1.9-2) ... 256s Setting up libgles2:armhf (1.7.0-1build1) ... 256s Setting up libfreetype6:armhf (2.13.3+dfsg-1) ... 256s Setting up libxcb-sync1:armhf (1.17.0-2) ... 256s Setting up python3-werkzeug (3.1.3-2) ... 256s Setting up python3-brotli (1.1.0-2build4) ... 257s Setting up libavahi-common-data:armhf (0.8-16ubuntu2) ... 257s Setting up python3-greenlet (3.1.0-1build1) ... 257s Setting up python3-cycler (0.12.1-1) ... 257s Setting up libimagequant0:armhf (2.18.0-1build1) ... 257s Setting up libxkbcommon-x11-0:armhf (1.7.0-2) ... 257s Setting up fonts-dejavu-mono (2.37-8) ... 257s Setting up python3-kiwisolver (1.4.7-3build1) ... 257s Setting up python3-bottleneck (1.4.2+ds1-2build1) ... 257s Setting up libxrandr2:armhf (2:1.5.4-1) ... 257s Setting up libtcl8.6:armhf (8.6.16+dfsg-1) ... 257s Setting up fonts-dejavu-core (2.37-8) ... 257s Setting up python3-numexpr (2.10.2-1build2) ... 258s Setting up libjpeg-turbo8:armhf (2.1.5-3ubuntu2) ... 258s Setting up python3-cpuinfo (9.0.0+git20221119-3) ... 258s Setting up python3-html5lib (1.2-2) ... 258s Setting up libvulkan1:armhf (1.4.309.0-1) ... 258s Setting up python3-pluggy (1.5.0-1) ... 258s Setting up libwebp7:armhf (1.5.0-0.1) ... 258s Setting up python3-pyqt5.sip (12.17.0-1build1) ... 258s Setting up libmtdev1t64:armhf (1.1.7-1) ... 258s Setting up libxshmfence1:armhf (1.3.3-1) ... 258s Setting up libxcb-randr0:armhf (1.17.0-2) ... 258s Setting up libxslt1.1:armhf (1.1.39-0exp1ubuntu4) ... 258s Setting up libblosc1:armhf (1.21.5+ds-1build1) ... 258s Setting up python3-et-xmlfile (2.0.0-1) ... 259s Setting up libqt5sql5t64:armhf (5.15.15+dfsg-4ubuntu1) ... 259s Setting up libmd4c0:armhf (0.5.2-2) ... 259s Setting up python3-xlrd (2.0.1-2) ... 259s Setting up libopenjp2-7:armhf (2.5.3-2) ... 259s Setting up python3-toolz (1.0.0-2) ... 259s Setting up libharfbuzz0b:armhf (10.2.0-1) ... 259s Setting up python3-contourpy (1.3.1-1build1) ... 259s Setting up libxss1:armhf (1:1.2.3-1build3) ... 259s Setting up libxkbfile1:armhf (1:1.1.0-1build4) ... 259s Setting up libjs-jquery (3.6.1+dfsg+~3.5.14-1) ... 259s Setting up python3-mpmath (1.3.0-1) ... 260s Setting up python3-execnet (2.1.1-1) ... 260s Setting up python-matplotlib-data (3.10.1+dfsg1-3) ... 260s Setting up libwebpmux3:armhf (1.5.0-0.1) ... 260s Setting up python3-locket (1.0.0-2) ... 260s Setting up libxfont2:armhf (1:2.0.6-1build1) ... 260s Setting up python3-soupsieve (2.7-1) ... 261s Setting up python-tables-data (3.10.2-2build1) ... 261s Setting up libsz2:armhf (1.1.3-1) ... 261s Setting up liblbfgsb0:armhf (3.0+dfsg.4-1build1) ... 261s Setting up python3-odf (1.4.2-4) ... 261s Setting up libwacom-common (2.14.0-1) ... 261s Setting up libwayland-client0:armhf (1.23.1-3) ... 261s Setting up libjpeg8:armhf (8c-2ubuntu11) ... 261s Setting up python3-partd (1.4.2-1) ... 261s Setting up python3-sympy (1.13.3-5) ... 270s Setting up libice6:armhf (2:1.1.1-1) ... 270s Setting up mesa-libgallium:armhf (25.0.3-1ubuntu2) ... 270s Setting up libqt5dbus5t64:armhf (5.15.15+dfsg-4ubuntu1) ... 270s Setting up python3-scipy (1.14.1-4ubuntu2) ... 275s Setting up libgbm1:armhf (25.0.3-1ubuntu2) ... 275s Setting up libwacom9:armhf (2.14.0-1) ... 275s Setting up fontconfig-config (2.15.0-2.2ubuntu1) ... 275s Setting up python3-pytest (8.3.5-1) ... 276s Setting up python3-pytest-localserver (0.9.0.post0-1) ... 276s Setting up libwebpdemux2:armhf (1.5.0-0.1) ... 276s Setting up python3-hypothesis (6.127.4-1) ... 277s Setting up libgl1-mesa-dri:armhf (25.0.3-1ubuntu2) ... 277s Setting up libqt5network5t64:armhf (5.15.15+dfsg-4ubuntu1) ... 277s Setting up libavahi-common3:armhf (0.8-16ubuntu2) ... 277s Setting up python3-dask (2024.12.1+dfsg-2) ... 279s Setting up libqt5xml5t64:armhf (5.15.15+dfsg-4ubuntu1) ... 279s Setting up libqt5test5t64:armhf (5.15.15+dfsg-4ubuntu1) ... 279s Setting up python3-bs4 (4.13.4-1) ... 279s Setting up python3-sqlalchemy (2.0.38+ds1-0ubuntu2) ... 281s Setting up libinput-bin (1.28.1-1) ... 281s Setting up python3-pytest-forked (1.6.0-3) ... 281s Setting up libegl-mesa0:armhf (25.0.3-1ubuntu2) ... 281s Setting up libjs-jquery-ui (1.13.2+dfsg-1) ... 281s Setting up libraqm0:armhf (0.10.2-1) ... 281s Setting up python3-pytest-asyncio (0.25.1-1) ... 281s Setting up libhdf5-310:armhf (1.14.5+repack-3) ... 281s Setting up python3-lxml:armhf (5.4.0-1) ... 282s Setting up libtiff6:armhf (4.7.0-3ubuntu1) ... 282s Setting up libegl1:armhf (1.7.0-1build1) ... 282s Setting up libfontconfig1:armhf (2.15.0-2.2ubuntu1) ... 282s Setting up libsm6:armhf (2:1.2.6-1) ... 282s Setting up python3-pytestqt (4.4.0-1) ... 282s Setting up libavahi-client3:armhf (0.8-16ubuntu2) ... 282s Setting up libinput10:armhf (1.28.1-1) ... 282s Setting up fontconfig (2.15.0-2.2ubuntu1) ... 284s Regenerating fonts cache... done. 284s Setting up libxft2:armhf (2.3.6-1build1) ... 284s Setting up libglx-mesa0:armhf (25.0.3-1ubuntu2) ... 284s Setting up python3-pytest-xdist (3.6.1-1) ... 284s Setting up libglx0:armhf (1.7.0-1build1) ... 284s Setting up python3-tables-lib (3.10.2-2build1) ... 284s Setting up libtk8.6:armhf (8.6.16-1) ... 284s Setting up python3-tables (3.10.2-2build1) ... 285s Setting up python3.13-tk (3.13.3-1) ... 285s Setting up python3-pil:armhf (11.1.0-5build1) ... 286s Setting up libqt5gui5t64:armhf (5.15.15+dfsg-4ubuntu1) ... 286s Setting up libgl1:armhf (1.7.0-1build1) ... 286s Setting up python3-openpyxl (3.1.5+dfsg-2) ... 286s Setting up libxt6t64:armhf (1:1.2.1-1.2build1) ... 286s Setting up libcups2t64:armhf (2.4.12-0ubuntu1) ... 286s Setting up tk8.6-blt2.5 (2.5.3+dfsg-8) ... 286s Setting up libxmu6:armhf (2:1.1.3-3build2) ... 286s Setting up libqt5widgets5t64:armhf (5.15.15+dfsg-4ubuntu1) ... 286s Setting up blt (2.5.3+dfsg-8) ... 286s Setting up python3-tk:armhf (3.13.3-1) ... 286s Setting up libxaw7:armhf (2:1.0.16-1) ... 286s Setting up libqt5help5:armhf (5.15.15-6build1) ... 286s Setting up python3-pil.imagetk:armhf (11.1.0-5build1) ... 286s Setting up libqt5printsupport5t64:armhf (5.15.15+dfsg-4ubuntu1) ... 286s Setting up libqt5designer5:armhf (5.15.15-6build1) ... 286s Setting up x11-xkb-utils (7.7+9) ... 286s Setting up xserver-common (2:21.1.16-1ubuntu1) ... 286s Setting up python3-pyqt5 (5.15.11+dfsg-2) ... 286s Setting up xvfb (2:21.1.16-1ubuntu1) ... 286s Setting up python3-fonttools (4.55.3-2build1) ... 287s Setting up python3-ufolib2 (0.17.1+dfsg1-1) ... 288s Setting up python3-matplotlib (3.10.1+dfsg1-3) ... 290s Processing triggers for libc-bin (2.41-6ubuntu1) ... 290s Processing triggers for man-db (2.13.1-1) ... 290s Processing triggers for udev (257.4-1ubuntu3) ... 298s autopkgtest [17:28:37]: test unittests3: [----------------------- 300s ++ dpkg --print-architecture 300s + arch=armhf 300s ++ py3versions -s 300s + pys=python3.13 300s + sourcetestroot=/tmp/autopkgtest.gY8OYq/build.DBr/src/pandas/tests 300s + tomlfile=/tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml 300s + echo amd64 i386 300s + grep armhf 300s + marker='not slow' 300s + echo armhf 300s + grep -E 'mips|hppa' 300s === python3.13 === 300s + PYTEST_WARN_IGNORE= 300s + cd /tmp/autopkgtest.gY8OYq/autopkgtest_tmp 300s + TEST_SUCCESS=true 300s + for py in $pys 300s + echo '=== python3.13 ===' 300s ++ python3.13 -c 'import pandas as pd; print(pd.__path__[0])' 301s + modpath=/usr/lib/python3/dist-packages/pandas 301s + for TEST_SUBSET in $modpath/tests/* 301s + echo /usr/lib/python3/dist-packages/pandas/tests/__init__.py 301s + grep -q -e __pycache__ 301s + PANDAS_CI=1 301s + LC_ALL=C.UTF-8 301s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.gY8OYq/build.DBr/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/__init__.py 302s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 302s 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" 302s 302s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 302s ============================= test session starts ============================== 302s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 302s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 302s rootdir: /usr/lib/python3/dist-packages/pandas 302s configfile: ../../../../../tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml 302s plugins: typeguard-4.4.2, hypothesis-6.127.4, asyncio-0.25.1, forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, qt-4.4.0 302s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 302s collected 0 items 302s 302s =============================== warnings summary =============================== 302s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 302s /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-_8mbn4f3' 302s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 302s 302s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 302s /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-0lw8ftwd' 302s session.config.cache.set(STEPWISE_CACHE_DIR, []) 302s 302s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 302s -- generated xml file: /tmp/autopkgtest.gY8OYq/autopkgtest_tmp/test-data.xml --- 302s ============================= 2 warnings in 0.11s ============================== 303s rdjoqkol test state = true 303s rdjoqkol test state = true 303s + test 5 == 5 303s + echo 'rdjoqkol test state = true' 303s + for TEST_SUBSET in $modpath/tests/* 303s + echo /usr/lib/python3/dist-packages/pandas/tests/__pycache__ 303s + grep -q -e __pycache__ 303s + echo 'rdjoqkol test state = true' 303s + for TEST_SUBSET in $modpath/tests/* 303s + echo /usr/lib/python3/dist-packages/pandas/tests/api 303s + grep -q -e __pycache__ 303s + PANDAS_CI=1 303s + LC_ALL=C.UTF-8 303s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.gY8OYq/build.DBr/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/api 304s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 304s 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" 304s 304s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 304s ============================= test session starts ============================== 304s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 304s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 304s rootdir: /usr/lib/python3/dist-packages/pandas 304s configfile: ../../../../../tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml 304s plugins: typeguard-4.4.2, hypothesis-6.127.4, asyncio-0.25.1, forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, qt-4.4.0 304s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 304s collected 14 items 304s 304s ../../../usr/lib/python3/dist-packages/pandas/tests/api/test_api.py ............ 304s ../../../usr/lib/python3/dist-packages/pandas/tests/api/test_types.py .. 304s 304s =============================== warnings summary =============================== 304s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 304s /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-2rkrt323' 304s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 304s 304s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 304s /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-2uxli7xi' 304s session.config.cache.set(STEPWISE_CACHE_DIR, []) 304s 304s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 304s -- generated xml file: /tmp/autopkgtest.gY8OYq/autopkgtest_tmp/test-data.xml --- 304s ============================= slowest 30 durations ============================= 304s 304s (30 durations < 0.005s hidden. Use -vv to show these durations.) 304s ======================== 14 passed, 2 warnings in 0.18s ======================== 305s + echo 'rdjoqkol test state = true' 305s + for TEST_SUBSET in $modpath/tests/* 305s + echo /usr/lib/python3/dist-packages/pandas/tests/apply 305s + grep -q -e __pycache__ 305s + PANDAS_CI=1 305s + LC_ALL=C.UTF-8 305s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.gY8OYq/build.DBr/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/apply 305s rdjoqkol test state = true 306s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 306s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 306s 306s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 307s ============================= test session starts ============================== 307s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 307s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 307s rootdir: /usr/lib/python3/dist-packages/pandas 307s configfile: ../../../../../tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml 307s plugins: typeguard-4.4.2, hypothesis-6.127.4, asyncio-0.25.1, forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, qt-4.4.0 307s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 307s collected 1243 items 307s 309s ../../../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....... 309s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_frame_apply_relabeling.py ..x.. 311s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_frame_transform.py ...s.s.s................................................ss..ss..ss.....x........x........x........ 312s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_invalid_arg.py ....................................................................................................................................................................................................... 312s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_numba.py sssssssssssssssssss 312s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_series_apply.py ................................x.....x....x........................................................................................ 312s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_series_apply_relabeling.py .. 312s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_series_transform.py ............ 318s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_str.py ....................xxxxx...................................................................................................................................................................................................................................................................................................................................................................................................................................................................x...........x...........x...........x...........x........ 318s 318s =============================== warnings summary =============================== 318s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 318s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-8_4j3256' 318s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 318s 318s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 318s /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-7z_jlhpk' 318s session.config.cache.set(STEPWISE_CACHE_DIR, []) 318s 318s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 318s -- generated xml file: /tmp/autopkgtest.gY8OYq/autopkgtest_tmp/test-data.xml --- 318s ============================= slowest 30 durations ============================= 318s 0.14s call tests/apply/test_frame_apply.py::test_apply_differently_indexed 318s 0.05s call tests/apply/test_frame_apply.py::test_agg_transform[axis=1] 318s 0.04s call tests/apply/test_frame_apply.py::test_agg_transform[axis='columns'] 318s 0.04s call tests/apply/test_series_apply.py::test_transform[False] 318s 0.04s call tests/apply/test_series_apply.py::test_transform[compat] 318s 0.03s call tests/apply/test_frame_apply.py::test_agg_reduce[axis=1] 318s 0.03s call tests/apply/test_frame_apply.py::test_agg_reduce[axis='columns'] 318s 0.02s call tests/apply/test_frame_transform.py::test_transform_listlike[axis=1-ops1-names1] 318s 0.02s call tests/apply/test_frame_transform.py::test_transform_listlike[axis='columns'-ops1-names1] 318s 0.02s call tests/apply/test_frame_transform.py::test_transform_listlike[axis='columns'-ops3-names3] 318s 0.02s call tests/apply/test_frame_transform.py::test_transform_listlike[axis=1-ops3-names3] 318s 0.02s call tests/apply/test_frame_transform.py::test_transform_listlike[axis='columns'-ops0-names0] 318s 0.02s call tests/apply/test_str.py::test_transform_groupby_kernel_frame[axis=1-pct_change] 318s 0.02s call tests/apply/test_frame_transform.py::test_transform_listlike[axis=1-ops0-names0] 318s 0.02s call tests/apply/test_str.py::test_transform_groupby_kernel_frame[axis='columns'-pct_change] 318s 0.02s call tests/apply/test_frame_transform.py::test_transform_listlike[axis='columns'-ops2-names2] 318s 0.02s call tests/apply/test_frame_transform.py::test_transform_listlike[axis=1-ops2-names2] 318s 0.01s call tests/apply/test_str.py::test_transform_groupby_kernel_frame[axis='index'-pct_change] 318s 0.01s call tests/apply/test_str.py::test_transform_groupby_kernel_frame[axis=0-pct_change] 318s 0.01s call tests/apply/test_frame_apply_relabeling.py::test_agg_namedtuple 318s 0.01s call tests/apply/test_frame_apply.py::test_agg_reduce[axis=0] 318s 0.01s call tests/apply/test_frame_apply.py::test_agg_reduce[axis='index'] 318s 0.01s call tests/apply/test_series_apply.py::test_with_nested_series[agg] 318s 0.01s call tests/apply/test_series_apply.py::test_with_nested_series[apply] 318s 0.01s call tests/apply/test_frame_apply.py::test_agg_transform[axis=0] 318s 0.01s call tests/apply/test_frame_apply_relabeling.py::test_agg_relabel 318s 0.01s call tests/apply/test_str.py::test_transform_groupby_kernel_frame[axis=1-fillna] 318s 0.01s call tests/apply/test_frame_apply.py::test_agg_transform[axis='index'] 318s 0.01s call tests/apply/test_str.py::test_transform_groupby_kernel_frame[axis='columns'-fillna] 318s 0.01s call tests/apply/test_frame_apply_relabeling.py::test_agg_relabel_partial_functions 318s ========== 1153 passed, 73 skipped, 17 xfailed, 2 warnings in 11.98s =========== 319s rdjoqkol test state = true 319s + echo 'rdjoqkol test state = true' 319s + for TEST_SUBSET in $modpath/tests/* 319s + echo /usr/lib/python3/dist-packages/pandas/tests/arithmetic 319s + grep -q -e __pycache__ 319s + PANDAS_CI=1 319s + LC_ALL=C.UTF-8 319s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.gY8OYq/build.DBr/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/arithmetic 320s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 320s 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" 320s 320s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 322s ============================= test session starts ============================== 322s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 322s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 322s rootdir: /usr/lib/python3/dist-packages/pandas 322s configfile: ../../../../../tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml 322s plugins: typeguard-4.4.2, hypothesis-6.127.4, asyncio-0.25.1, forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, qt-4.4.0 322s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 322s collected 19330 items 322s 322s ../../../usr/lib/python3/dist-packages/pandas/tests/arithmetic/test_array_ops.py .. 322s ../../../usr/lib/python3/dist-packages/pandas/tests/arithmetic/test_categorical.py .. 426s ../../../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................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 430s ../../../usr/lib/python3/dist-packages/pandas/tests/arithmetic/test_interval.py ............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 441s ../../../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............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 442s ../../../usr/lib/python3/dist-packages/pandas/tests/arithmetic/test_object.py .......s........................................................................................... 444s ../../../usr/lib/python3/dist-packages/pandas/tests/arithmetic/test_period.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 451s ../../../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......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 451s 451s =============================== warnings summary =============================== 451s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 451s /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-pr5bz80s' 451s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 451s 451s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 451s /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-xmklood5' 451s session.config.cache.set(STEPWISE_CACHE_DIR, []) 451s 451s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 451s -- generated xml file: /tmp/autopkgtest.gY8OYq/autopkgtest_tmp/test-data.xml --- 451s ============================= slowest 30 durations ============================= 451s 0.67s call tests/arithmetic/test_datetime64.py::TestDatetimeIndexArithmetic::test_dti_addsub_offset_arraylike[zoneinfo.ZoneInfo(key='US/Pacific')-names3-series-add] 451s 0.34s call tests/arithmetic/test_datetime64.py::TestDatetime64Arithmetic::test_dt64arr_sub_timedeltalike_scalar[tzutc()-timedelta64_1-DataFrame] 451s 0.15s teardown tests/arithmetic/test_timedelta64.py::test_add_timestamp_to_timedelta 451s 0.10s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_relativedelta_offsets[DataFrame-us] 451s 0.10s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_relativedelta_offsets[DataFrame-ms] 451s 0.10s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_relativedelta_offsets[DataFrame-s] 451s 0.10s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_relativedelta_offsets[DataFrame-ns] 451s 0.09s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-us-5-True-cls_and_kwargs27] 451s 0.09s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-ms-5-True-cls_and_kwargs27] 451s 0.08s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-s-5-True-cls_and_kwargs27] 451s 0.08s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-us-5-False-cls_and_kwargs27] 451s 0.07s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-ms-0-True-CBMonthBegin] 451s 0.07s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-s-5-False-cls_and_kwargs27] 451s 0.07s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-ms-5-True-CBMonthBegin] 451s 0.07s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-ms-5-True-CBMonthEnd] 451s 0.07s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-ms-0-True-CBMonthEnd] 451s 0.07s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-s-0-True-CBMonthBegin] 451s 0.07s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-s-5-True-CBMonthBegin] 451s 0.06s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-s-5-True-CBMonthEnd] 451s 0.06s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-s-0-True-CBMonthEnd] 451s 0.06s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-us-5-True-CBMonthBegin] 451s 0.06s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-us-5-False-CBMonthBegin] 451s 0.06s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[Series-US/Central-s-5-False-cls_and_kwargs27] 451s 0.06s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-ms-0-False-CBMonthBegin] 451s 0.06s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-ms-5-False-CBMonthBegin] 451s 0.06s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-ms-5-False-cls_and_kwargs27] 451s 0.06s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-us-5-False-CBMonthEnd] 451s 0.06s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-us-0-True-CBMonthBegin] 451s 0.06s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-s-0-False-CBMonthBegin] 451s 0.06s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-us-5-True-CBMonthEnd] 451s ========== 19158 passed, 172 skipped, 2 warnings in 131.52s (0:02:11) ========== 454s + echo 'rdjoqkol test state = true' 454s + for TEST_SUBSET in $modpath/tests/* 454s rdjoqkol test state = true 454s + echo /usr/lib/python3/dist-packages/pandas/tests/arrays 454s + grep -q -e __pycache__ 454s + PANDAS_CI=1 454s + LC_ALL=C.UTF-8 454s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.gY8OYq/build.DBr/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/arrays 455s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 455s 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" 455s 455s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 459s ============================= test session starts ============================== 459s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 459s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 459s rootdir: /usr/lib/python3/dist-packages/pandas 459s configfile: ../../../../../tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml 459s plugins: typeguard-4.4.2, hypothesis-6.127.4, asyncio-0.25.1, forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, qt-4.4.0 459s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 459s collected 19230 items / 2 skipped 459s 459s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_arithmetic.py ..................... 459s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_astype.py ... 459s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_comparison.py .................................... 460s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_construction.py ............................. 460s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_function.py ........... 460s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_indexing.py ... 460s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_logical.py ................................................................................... 460s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_ops.py .. 460s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_reduction.py .............................. 460s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_repr.py . 460s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_algos.py .............. 460s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_analytics.py ........x..x................................................ 460s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_api.py ................................................................. 460s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_astype.py ...................... 461s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_constructors.py ....................................................................................................................... 461s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_dtypes.py .................................. 461s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_indexing.py ............................................................................................................................................... 461s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_map.py ............................. 461s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_missing.py .......................... 462s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_operators.py ...................................... 462s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_replace.py ...................... 462s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_repr.py ....................... 462s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_sorting.py .... 462s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_subclass.py ... 462s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_take.py ................ 462s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_warnings.py s 462s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/datetimes/test_constructors.py ......................ssssssssssssss 462s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/datetimes/test_cumulative.py ... 462s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/datetimes/test_reductions.py ................................................................................................................................................................................................................. 463s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_arithmetic.py .............................................................. 463s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_astype.py ......... 463s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_comparison.py .................................................................................................................. 463s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_concat.py ... 463s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_construction.py ............................... 463s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_contains.py . 463s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_function.py ...........sssssss.................................. 463s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_repr.py ........ 463s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_to_numpy.py .............................. 464s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_arithmetic.py ................................................................................................................................................................................................................................................................................................................................................... 465s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_comparison.py ......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 465s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_concat.py .................. 466s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_construction.py ............................................... 466s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_dtypes.py ......................................................................................................................... 466s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_function.py ............................................................................................................................. 466s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_indexing.py .. 466s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_reduction.py ............................................... 466s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_repr.py .......................... 466s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/interval/test_astype.py .. 466s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/interval/test_formats.py . 467s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/interval/test_interval.py .............................................................................. 467s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/interval/test_interval_pyarrow.py ssssssss 467s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/interval/test_overlaps.py .................................................................................................................... 470s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/masked/test_arithmetic.py ..............................................................................................................................................ss........................................................................................................................................................ss........................................................................................................................................................ss........................................................................................................................................................ss........................................................................................................................................................ss............................................................................................................................................................................................................................................................................................................................................................... 470s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/masked/test_function.py ..................... 470s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/masked/test_indexing.py ........................................................................................................... 470s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/numpy_/test_indexing.py ....................................... 470s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/numpy_/test_numpy.py ....................................................................................... 470s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/period/test_astype.py .......... 470s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/period/test_constructors.py ..................... 470s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/period/test_reductions.py ... 471s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_accessor.py ............................................. 474s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_arithmetics.py ...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 474s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_array.py ........................................................................... 474s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_astype.py ........................ 474s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_combine_concat.py .......... 474s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_constructors.py ................................. 474s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_dtype.py ........................................................ 475s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_indexing.py ................................................................................ 475s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_libsparse.py ..................................................................................... 475s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_reductions.py ....................................................................... 475s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_unary.py ......... 477s ../../../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 477s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/string_/test_string_arrow.py s.ss.ssssssssss.ssssssssssssssssssssssssssssssssss 477s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/test_array.py ....................................................................................... 503s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/test_datetimelike.py ........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ssssss....................................................................................................................................................................................................ssssssssssssssssssssssssssssssssssss.......................................................................................................................................................................................................................................................................................................................................... 509s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/test_datetimes.py ........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 509s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/test_ndarray_backed.py ..... 509s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/test_period.py ................... 510s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/test_timedeltas.py ...................................................................................................................................................... 510s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/timedeltas/test_constructors.py ........ 510s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/timedeltas/test_cumulative.py ..... 510s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/timedeltas/test_reductions.py .......................... 510s 510s =============================== warnings summary =============================== 510s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 510s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-wf1m4qp4' 510s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 510s 510s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 510s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-dy4y7fku' 510s session.config.cache.set(STEPWISE_CACHE_DIR, []) 510s 510s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 510s -- generated xml file: /tmp/autopkgtest.gY8OYq/autopkgtest_tmp/test-data.xml --- 510s ============================= slowest 30 durations ============================= 510s 0.37s call tests/arrays/test_timedeltas.py::TestNonNano::test_mul_listlike_object[s] 510s 0.28s call tests/arrays/test_datetimelike.py::TestDatetimeArray::test_setitem_object_dtype['UTC+01:15'-QE-Index] 510s 0.26s setup tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_bool_array_logical[integer-True] 510s 0.21s call tests/arrays/sparse/test_accessor.py::TestSeriesAccessor::test_from_coo 510s 0.14s teardown tests/arrays/timedeltas/test_reductions.py::TestReductions::test_mean_2d 510s 0.06s call tests/arrays/categorical/test_dtypes.py::TestCategoricalDtypes::test_codes_dtypes 510s 0.03s call tests/arrays/sparse/test_accessor.py::TestFrameAccessor::test_from_spmatrix[int64-labels1-coo] 510s 0.03s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_mixed_array_comparison[block] 510s 0.03s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_mixed_array_comparison[integer] 510s 0.02s call tests/arrays/integer/test_arithmetic.py::test_values_multiplying_large_series_by_NA 510s 0.02s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_int_array_comparison[integer] 510s 0.02s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_float_scalar_comparison[block] 510s 0.02s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_int_array_comparison[block] 510s 0.02s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_float_array_comparison[integer] 510s 0.02s call tests/arrays/integer/test_reduction.py::test_mixed_reductions[median-expected5] 510s 0.01s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_float_array_comparison[block] 510s 0.01s call tests/arrays/floating/test_arithmetic.py::test_unary_float_operators[Float32-source2-neg_target2-abs_target2] 510s 0.01s setup tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_float_scalar[block-False-rpow-2-3] 510s 0.01s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_float_scalar_comparison[integer] 510s 0.01s call tests/arrays/integer/test_comparison.py::TestComparisonOps::test_scalar[le-Int8Dtype-0] 510s 0.01s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_int_array[integer-True-rmul] 510s 0.01s call tests/arrays/test_datetimes.py::TestNonNano::test_format_native_types[us-'dateutil/US/Pacific'] 510s 0.01s call tests/arrays/categorical/test_api.py::TestCategoricalAPIWithFactor::test_describe 510s 0.01s call tests/arrays/test_datetimelike.py::TestDatetimeArray::test_compare_categorical_dtype[False-pytz.FixedOffset(-300)-QE-True-False] 510s 0.01s call tests/arrays/test_datetimes.py::TestNonNano::test_format_native_types[ms-'dateutil/US/Pacific'] 510s 0.01s call tests/arrays/test_datetimelike.py::TestDatetimeArray::test_compare_categorical_dtype[False--D-True-False] 510s 0.01s setup tests/arrays/categorical/test_constructors.py::TestCategoricalConstructors::test_from_codes_nullable_int_categories[UInt8-False] 510s 0.01s call tests/arrays/sparse/test_accessor.py::TestFrameAccessor::test_from_spmatrix[float64-None-csc] 510s 0.01s call tests/arrays/sparse/test_accessor.py::TestFrameAccessor::test_from_spmatrix[float64-None-coo] 510s 0.01s call tests/arrays/sparse/test_accessor.py::TestFrameAccessor::test_from_spmatrix[float64-None-csr] 510s ========= 18196 passed, 1028 skipped, 8 xfailed, 2 warnings in 55.20s ========== 512s rdjoqkol test state = true 512s + echo 'rdjoqkol test state = true' 512s + for TEST_SUBSET in $modpath/tests/* 512s + echo /usr/lib/python3/dist-packages/pandas/tests/base 512s + grep -q -e __pycache__ 512s + PANDAS_CI=1 512s + LC_ALL=C.UTF-8 512s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.gY8OYq/build.DBr/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/base 513s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 513s 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" 513s 513s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 513s ============================= test session starts ============================== 513s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 513s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 513s rootdir: /usr/lib/python3/dist-packages/pandas 513s configfile: ../../../../../tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml 513s plugins: typeguard-4.4.2, hypothesis-6.127.4, asyncio-0.25.1, forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, qt-4.4.0 513s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 513s collected 1775 items 513s 513s ../../../usr/lib/python3/dist-packages/pandas/tests/base/test_constructors.py ....................... 514s ../../../usr/lib/python3/dist-packages/pandas/tests/base/test_conversion.py ................................................................................................................................................................................................................................................................................................................................... 514s ../../../usr/lib/python3/dist-packages/pandas/tests/base/test_fillna.py ..................................................................................ssssssssssssssssss....ssss........ssssssssss......ss..............................................ss......................ssssssssssss 515s ../../../usr/lib/python3/dist-packages/pandas/tests/base/test_misc.py .......................................................................................................................................................................................................................................xx...xxx....................................................................s...... 515s ../../../usr/lib/python3/dist-packages/pandas/tests/base/test_transpose.py .............................................................................................................................................................................................................................. 517s ../../../usr/lib/python3/dist-packages/pandas/tests/base/test_unique.py ..................................................................................ssssssssssssssssss....ssss........ssssssssss......ss..............................................ss......................ssssssssssss..................................................................................ssssssssssssssssss....ssss..........ssssssss......ss......................................................................ssssssssssss.... 518s ../../../usr/lib/python3/dist-packages/pandas/tests/base/test_value_counts.py ..................................................................................ssssssssssssssssss....ssss........ssssssssss......ss..............................................ss......................ssssssssssss......................... 518s 518s =============================== warnings summary =============================== 518s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 518s /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-agvegizd' 518s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 518s 518s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 518s /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-ccngya71' 518s session.config.cache.set(STEPWISE_CACHE_DIR, []) 518s 518s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 518s -- generated xml file: /tmp/autopkgtest.gY8OYq/autopkgtest_tmp/test-data.xml --- 518s ============================= slowest 30 durations ============================= 518s 0.07s setup tests/base/test_misc.py::test_memory_usage[datetime] 518s 0.04s call tests/base/test_value_counts.py::test_value_counts_null[interval-None] 518s 0.04s call tests/base/test_value_counts.py::test_value_counts_null[interval-nan] 518s 0.03s call tests/base/test_value_counts.py::test_value_counts[interval] 518s 0.02s call tests/base/test_value_counts.py::test_value_counts_null[datetime-tz-nan] 518s 0.02s call tests/base/test_value_counts.py::test_value_counts_null[datetime-tz-None] 518s 0.02s call tests/base/test_value_counts.py::test_value_counts_null[timedelta-nan] 518s 0.02s call tests/base/test_value_counts.py::test_value_counts_bins[index] 518s 0.02s call tests/base/test_value_counts.py::test_value_counts[datetime-tz] 518s 0.02s call tests/base/test_value_counts.py::test_value_counts_null[timedelta-None] 518s 0.02s call tests/base/test_value_counts.py::test_value_counts_bins[series] 518s 0.02s call tests/base/test_value_counts.py::test_value_counts_null[period-nan] 518s 0.02s call tests/base/test_unique.py::test_unique[datetime-tz] 518s 0.02s call tests/base/test_value_counts.py::test_value_counts_null[period-None] 518s 0.01s call tests/base/test_unique.py::test_unique_null[datetime-tz-nan] 518s 0.01s call tests/base/test_value_counts.py::test_value_counts[timedelta] 518s 0.01s call tests/base/test_unique.py::test_unique_null[datetime-tz-None] 518s 0.01s call tests/base/test_unique.py::test_unique_null[datetime-nan] 518s 0.01s call tests/base/test_unique.py::test_unique_null[timedelta-None] 518s 0.01s call tests/base/test_unique.py::test_unique_null[timedelta-nan] 518s 0.01s call tests/base/test_unique.py::test_unique_null[datetime-None] 518s 0.01s call tests/base/test_unique.py::test_unique[timedelta] 518s 0.01s call tests/base/test_unique.py::test_unique[datetime] 518s 0.01s call tests/base/test_value_counts.py::test_value_counts[period] 518s 0.01s call tests/base/test_value_counts.py::test_value_counts_null[datetime-nan] 518s 0.01s call tests/base/test_unique.py::test_unique_null[period-nan] 518s 0.01s call tests/base/test_value_counts.py::test_value_counts_null[datetime-None] 518s 0.01s call tests/base/test_value_counts.py::test_value_counts[datetime] 518s 0.01s call tests/base/test_value_counts.py::test_value_counts_null[string-python-nan] 518s 0.01s teardown tests/base/test_value_counts.py::test_value_counts_object_inference_deprecated 518s =========== 1581 passed, 189 skipped, 5 xfailed, 2 warnings in 4.88s =========== 518s rdjoqkol test state = true 518s + echo 'rdjoqkol test state = true' 518s + for TEST_SUBSET in $modpath/tests/* 518s + echo /usr/lib/python3/dist-packages/pandas/tests/computation 518s + grep -q -e __pycache__ 518s + PANDAS_CI=1 518s + LC_ALL=C.UTF-8 518s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.gY8OYq/build.DBr/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/computation 519s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 519s 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" 519s 519s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 520s ============================= test session starts ============================== 520s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 520s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 520s rootdir: /usr/lib/python3/dist-packages/pandas 520s configfile: ../../../../../tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml 520s plugins: typeguard-4.4.2, hypothesis-6.127.4, asyncio-0.25.1, forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, qt-4.4.0 520s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 520s collected 11159 items 520s 520s ../../../usr/lib/python3/dist-packages/pandas/tests/computation/test_compat.py ..... 596s ../../../usr/lib/python3/dist-packages/pandas/tests/computation/test_eval.py ..............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................xx..............................xx..............................xx..............................xx.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................xxxxxxxxxx..................................................xxxxxxxxxx......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................X.........X....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................x....................................................................................................................................................................................................................................xx..xx..... 596s 596s =============================== warnings summary =============================== 596s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 596s /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-2z8zdli7' 596s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 596s 596s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 596s /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-hk9486uv' 596s session.config.cache.set(STEPWISE_CACHE_DIR, []) 596s 596s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 596s -- generated xml file: /tmp/autopkgtest.gY8OYq/autopkgtest_tmp/test-data.xml --- 596s ============================= slowest 30 durations ============================= 596s 0.23s teardown tests/computation/test_eval.py::TestEval::test_floor_division[DataFrame-SeriesNaN-numexpr-python] 596s 0.12s call tests/computation/test_eval.py::TestEval::test_complex_cmp_ops[SeriesNaN-Series-numexpr-python-and-lt-ge] 596s 0.11s call tests/computation/test_eval.py::TestAlignment::test_performance_warning_for_poor_alignment[numexpr-python] 596s 0.08s call tests/computation/test_eval.py::TestAlignment::test_performance_warning_for_poor_alignment[numexpr-pandas] 596s 0.06s teardown tests/computation/test_eval.py::TestValidate::test_validate_bool_args[5.0] 596s 0.05s call tests/computation/test_eval.py::TestAlignment::test_performance_warning_for_poor_alignment[python-python] 596s 0.05s call tests/computation/test_eval.py::TestAlignment::test_performance_warning_for_poor_alignment[python-pandas] 596s 0.02s call tests/computation/test_eval.py::TestOperations::test_simple_arith_ops[numexpr-python] 596s 0.02s call tests/computation/test_eval.py::TestOperations::test_lhs_expression_subscript 596s 0.02s call tests/computation/test_eval.py::TestEval::test_simple_cmp_ops[DataFrame-DataFrameNaN-python-pandas->] 596s 0.02s call tests/computation/test_eval.py::TestOperations::test_nested_period_index_subscript_expression 596s 0.02s call tests/computation/test_eval.py::TestOperations::test_simple_arith_ops[numexpr-pandas] 596s 0.02s call tests/computation/test_eval.py::TestOperations::test_fails_ampersand_pipe[numexpr-pandas-&] 596s 0.02s call tests/computation/test_eval.py::TestOperations::test_fails_ampersand_pipe[numexpr-python-|] 596s 0.02s call tests/computation/test_eval.py::TestOperations::test_fails_ampersand_pipe[numexpr-pandas-|] 596s 0.01s call tests/computation/test_eval.py::TestOperations::test_fails_ampersand_pipe[numexpr-python-&] 596s 0.01s call tests/computation/test_eval.py::TestOperations::test_fails_ampersand_pipe[python-pandas-&] 596s 0.01s call tests/computation/test_eval.py::TestOperations::test_fails_ampersand_pipe[python-pandas-|] 596s 0.01s call tests/computation/test_eval.py::TestOperations::test_attr_expression 596s 0.01s call tests/computation/test_eval.py::TestOperations::test_fails_ampersand_pipe[python-python-|] 596s 0.01s call tests/computation/test_eval.py::TestOperations::test_fails_ampersand_pipe[python-python-&] 596s 0.01s call tests/computation/test_eval.py::TestOperations::test_multi_line_expression 596s 0.01s call tests/computation/test_eval.py::TestAlignment::test_medium_complex_frame_alignment[python-python-dt-dt-i-i] 596s 0.01s call tests/computation/test_eval.py::TestAlignment::test_medium_complex_frame_alignment[python-pandas-dt-dt-s-i] 596s 0.01s call tests/computation/test_eval.py::TestAlignment::test_medium_complex_frame_alignment[python-python-dt-dt-s-i] 596s 0.01s call tests/computation/test_eval.py::TestAlignment::test_medium_complex_frame_alignment[python-pandas-dt-dt-i-i] 596s 0.01s call tests/computation/test_eval.py::TestAlignment::test_medium_complex_frame_alignment[python-python-dt-i-s-dt] 596s 0.01s call tests/computation/test_eval.py::TestAlignment::test_medium_complex_frame_alignment[python-pandas-dt-i-s-dt] 596s 0.01s call tests/computation/test_eval.py::TestEval::test_chained_cmp_op[float-SeriesNaN-DataFrameNaN-numexpr-pandas-<-<] 596s 0.01s call tests/computation/test_eval.py::TestOperations::test_check_many_exprs[numexpr-python] 596s ===== 11124 passed, 33 xfailed, 2 xpassed, 2 warnings in 76.65s (0:01:16) ====== 597s rdjoqkol test state = true 597s + echo 'rdjoqkol test state = true' 597s + for TEST_SUBSET in $modpath/tests/* 597s + echo /usr/lib/python3/dist-packages/pandas/tests/config 597s + grep -q -e __pycache__ 597s + PANDAS_CI=1 597s + LC_ALL=C.UTF-8 597s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.gY8OYq/build.DBr/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/config 598s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 598s 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" 598s 598s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 599s ============================= test session starts ============================== 599s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 599s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 599s rootdir: /usr/lib/python3/dist-packages/pandas 599s configfile: ../../../../../tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml 599s plugins: typeguard-4.4.2, hypothesis-6.127.4, asyncio-0.25.1, forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, qt-4.4.0 599s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 599s collected 50 items 599s 599s ../../../usr/lib/python3/dist-packages/pandas/tests/config/test_config.py ..................... 599s ../../../usr/lib/python3/dist-packages/pandas/tests/config/test_localization.py ............................. 599s 599s =============================== warnings summary =============================== 599s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 599s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-aevvwuo9' 599s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 599s 599s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 599s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-lme4l5cc' 599s session.config.cache.set(STEPWISE_CACHE_DIR, []) 599s 599s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 599s -- generated xml file: /tmp/autopkgtest.gY8OYq/autopkgtest_tmp/test-data.xml --- 599s ============================= slowest 30 durations ============================= 599s 0.03s call tests/config/test_localization.py::test_get_locales_prefix 599s 0.01s call tests/config/test_localization.py::test_set_locale[zh_CN-GB2312] 599s 599s (28 durations < 0.005s hidden. Use -vv to show these durations.) 599s ======================== 50 passed, 2 warnings in 0.82s ======================== 599s + echo 'rdjoqkol test state = true' 599s + for TEST_SUBSET in $modpath/tests/* 599s rdjoqkol test state = true 599s + echo /usr/lib/python3/dist-packages/pandas/tests/construction 599s + grep -q -e __pycache__ 599s + PANDAS_CI=1 599s + LC_ALL=C.UTF-8 599s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.gY8OYq/build.DBr/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/construction 600s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 600s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 600s 600s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 600s ============================= test session starts ============================== 600s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 600s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 600s rootdir: /usr/lib/python3/dist-packages/pandas 600s configfile: ../../../../../tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml 600s plugins: typeguard-4.4.2, hypothesis-6.127.4, asyncio-0.25.1, forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, qt-4.4.0 600s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 600s collected 1 item 600s 600s ../../../usr/lib/python3/dist-packages/pandas/tests/construction/test_extract_array.py . 600s 600s =============================== warnings summary =============================== 600s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 600s /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-76s3m_mw' 600s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 600s 600s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 600s /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-b07avbcs' 600s session.config.cache.set(STEPWISE_CACHE_DIR, []) 600s 600s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 600s -- generated xml file: /tmp/autopkgtest.gY8OYq/autopkgtest_tmp/test-data.xml --- 600s ============================= slowest 30 durations ============================= 600s 600s (3 durations < 0.005s hidden. Use -vv to show these durations.) 600s ======================== 1 passed, 2 warnings in 0.10s ========================= 600s + echo 'rdjoqkol test state = true' 600s + for TEST_SUBSET in $modpath/tests/* 600s + echo /usr/lib/python3/dist-packages/pandas/tests/copy_view 600s + grep -q -e __pycache__ 600s rdjoqkol test state = true 600s + PANDAS_CI=1 600s + LC_ALL=C.UTF-8 600s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.gY8OYq/build.DBr/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/copy_view 601s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 601s 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" 601s 601s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 603s ============================= test session starts ============================== 603s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 603s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 603s rootdir: /usr/lib/python3/dist-packages/pandas 603s configfile: ../../../../../tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml 603s plugins: typeguard-4.4.2, hypothesis-6.127.4, asyncio-0.25.1, forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, qt-4.4.0 603s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 603s collected 793 items 603s 603s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/index/test_datetimeindex.py ...... 603s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/index/test_index.py ..................... 603s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/index/test_periodindex.py .. 603s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/index/test_timedeltaindex.py .. 603s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_array.py ............. 603s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_astype.py .....ss...s..........s.. 603s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_chained_assignment_deprecation.py ............... 603s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_clip.py ...... 603s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_constructors.py ............................................................................ 603s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_core_functionalities.py ....... 603s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_functions.py .................... 604s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_indexing.py ....................................................................................s.....s........................................................................................................................................ 605s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_internals.py ..................... 605s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_interp_fillna.py ...................................................... 606s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_methods.py ........................................................................................................................................................................................................................................................ 606s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_replace.py ........................................ 606s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_setitem.py ......... 606s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_util.py .. 606s 606s =============================== warnings summary =============================== 606s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 606s /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-nifhlpcm' 606s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 606s 606s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 606s /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-0yhnjouk' 606s session.config.cache.set(STEPWISE_CACHE_DIR, []) 606s 606s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 606s -- generated xml file: /tmp/autopkgtest.gY8OYq/autopkgtest_tmp/test-data.xml --- 606s ============================= slowest 30 durations ============================= 606s 0.03s call tests/copy_view/test_internals.py::test_exponential_backoff 606s 0.01s call tests/copy_view/test_indexing.py::test_midx_read_only_bool_indexer 606s 0.01s call tests/copy_view/test_indexing.py::test_subset_set_with_column_indexer[nullable-array] 606s 0.01s call tests/copy_view/test_indexing.py::test_subset_set_with_column_indexer[nullable-mask] 606s 0.01s call tests/copy_view/test_indexing.py::test_subset_set_with_column_indexer[nullable-slice] 606s 0.01s call tests/copy_view/test_indexing.py::test_subset_chained_getitem[nullable-mixed-block-column-getitem] 606s 0.01s call tests/copy_view/test_indexing.py::test_subset_chained_getitem[nullable-mixed-block-row-getitem-slice] 606s 0.01s call tests/copy_view/test_indexing.py::test_subset_chained_getitem[nullable-mixed-block-row-iloc-slice] 606s 0.01s call tests/copy_view/test_indexing.py::test_subset_chained_getitem[nullable-mixed-block-row-loc-slice] 606s 0.01s call tests/copy_view/test_indexing.py::test_subset_chained_getitem[nullable-single-block-row-getitem-slice] 606s 0.01s call tests/copy_view/test_indexing.py::test_subset_chained_getitem[nullable-single-block-column-getitem] 606s 0.01s call tests/copy_view/test_indexing.py::test_subset_chained_getitem[nullable-mixed-block-column-loc-slice] 606s 0.01s call tests/copy_view/test_indexing.py::test_subset_chained_getitem[nullable-single-block-row-loc-slice] 606s 0.01s call tests/copy_view/test_indexing.py::test_subset_chained_getitem[nullable-single-block-row-iloc-slice] 606s 0.01s call tests/copy_view/test_methods.py::test_chained_where_mask[mask] 606s 0.01s call tests/copy_view/test_replace.py::test_replace_list_categorical 606s 0.01s call tests/copy_view/test_indexing.py::test_subset_chained_getitem[nullable-mixed-block-column-iloc-slice] 606s 0.01s call tests/copy_view/test_indexing.py::test_subset_set_with_column_indexer[numpy-array] 606s 0.01s call tests/copy_view/test_methods.py::test_eval 606s 0.01s call tests/copy_view/test_indexing.py::test_subset_set_columns[nullable-mixed-block] 606s 0.01s call tests/copy_view/test_methods.py::test_chained_methods[reset_index] 606s 0.01s call tests/copy_view/test_indexing.py::test_subset_chained_getitem[nullable-single-block-column-loc-slice] 606s 0.01s call tests/copy_view/test_indexing.py::test_del_frame[nullable] 606s 0.01s call tests/copy_view/test_methods.py::test_groupby_column_index_in_references 606s 0.01s call tests/copy_view/test_methods.py::test_chained_where_mask[where] 606s 0.01s call tests/copy_view/test_indexing.py::test_subset_chained_getitem[nullable-single-block-column-iloc-slice] 606s 0.01s call tests/copy_view/test_indexing.py::test_subset_set_with_column_indexer[numpy-mask] 606s 0.01s call tests/copy_view/test_methods.py::test_update_chained_assignment 606s 0.01s call tests/copy_view/test_indexing.py::test_subset_set_with_column_indexer[numpy-slice] 606s 0.01s call tests/copy_view/test_interp_fillna.py::test_interpolate_chained_assignment[interpolate] 606s ================== 787 passed, 6 skipped, 2 warnings in 5.04s ================== 607s + echo 'rdjoqkol test state = true' 607s + for TEST_SUBSET in $modpath/tests/* 607s + echo /usr/lib/python3/dist-packages/pandas/tests/dtypes 607s + grep -q -e __pycache__ 607s rdjoqkol test state = true 607s + PANDAS_CI=1 607s + LC_ALL=C.UTF-8 607s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.gY8OYq/build.DBr/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/dtypes 608s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 608s 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" 608s 608s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 609s ============================= test session starts ============================== 609s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 609s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 609s rootdir: /usr/lib/python3/dist-packages/pandas 609s configfile: ../../../../../tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml 609s plugins: typeguard-4.4.2, hypothesis-6.127.4, asyncio-0.25.1, forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, qt-4.4.0 609s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 609s collected 5628 items 609s 609s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_can_hold_element.py ........... 609s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_construct_from_scalar.py .... 609s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_construct_ndarray.py ....... 609s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_construct_object_arr.py ....................................... 609s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_dict_compat.py . 610s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_downcast.py ................................... 610s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_find_common_type.py .......................................................................................... 610s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_infer_datetimelike.py ... 610s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_infer_dtype.py .................................................................... 610s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_maybe_box_native.py ................ 615s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_promote.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................. 616s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/test_common.py .............................................................................................................................................................................s...................................................................................................................................................................................................................................................................... 616s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/test_concat.py .... 616s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/test_dtypes.py ........................................................................................................................................................................................................................................................................................... 617s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/test_generic.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 618s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/test_inference.py .......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ssssssss....................................................... 619s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/test_missing.py ..........................................................................................................xxxx............................................................................................................................................................................................................. 619s 619s =============================== warnings summary =============================== 619s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 619s /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-0yis6p28' 619s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 619s 619s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 619s /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-428rlc7k' 619s session.config.cache.set(STEPWISE_CACHE_DIR, []) 619s 619s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 619s -- generated xml file: /tmp/autopkgtest.gY8OYq/autopkgtest_tmp/test-data.xml --- 619s ============================= slowest 30 durations ============================= 619s 0.12s call tests/dtypes/test_common.py::test_is_sparse[True] 619s 0.08s call tests/dtypes/test_inference.py::TestInference::test_maybe_convert_objects_mixed_datetimes 619s 0.03s teardown tests/dtypes/test_missing.py::TestIsValidNAForDtype::test_is_valid_na_for_dtype_categorical 619s 0.01s call tests/dtypes/cast/test_can_hold_element.py::test_can_hold_element_range[uint8] 619s 0.01s setup tests/dtypes/cast/test_promote.py::test_maybe_promote_any_with_datetime64[int16-pd.Timestamp] 619s 0.01s call tests/dtypes/cast/test_can_hold_element.py::test_can_hold_element_range[int8] 619s 0.01s call tests/dtypes/cast/test_can_hold_element.py::test_can_hold_element_range[int16] 619s 0.01s call tests/dtypes/cast/test_can_hold_element.py::test_can_hold_element_range[uint16] 619s 0.01s call tests/dtypes/cast/test_can_hold_element.py::test_can_hold_element_range[int32] 619s 0.01s call tests/dtypes/cast/test_can_hold_element.py::test_can_hold_element_range[int] 619s 0.01s call tests/dtypes/cast/test_can_hold_element.py::test_can_hold_element_range[uint64] 619s 0.01s call tests/dtypes/cast/test_can_hold_element.py::test_can_hold_element_range[uint32] 619s 0.01s call tests/dtypes/cast/test_can_hold_element.py::test_can_hold_element_range[int64] 619s 0.01s call tests/dtypes/cast/test_promote.py::test_maybe_promote_any_numpy_dtype_with_datetimetz[int16-tzlocal()-datetime.date] 619s 0.01s call tests/dtypes/cast/test_promote.py::test_maybe_promote_string_with_any[U-U] 619s 0.01s call tests/dtypes/test_generic.py::TestABCClasses::test_abc_pairs_instance_check[ABCRangeIndex-_2-ABCTimedeltaIndex-inst3] 619s 0.01s call tests/dtypes/cast/test_promote.py::test_maybe_promote_any_numpy_dtype_with_datetimetz[timedelta64[ns]-'Asia/Tokyo'-datetime.date] 619s 0.01s call tests/dtypes/test_inference.py::TestInference::test_maybe_convert_objects_datetime_overflow_safe[datetime64[ns]] 619s 619s (12 durations < 0.005s hidden. Use -vv to show these durations.) 619s =========== 5615 passed, 9 skipped, 4 xfailed, 2 warnings in 11.10s ============ 619s rdjoqkol test state = true 619s + echo 'rdjoqkol test state = true' 619s + for TEST_SUBSET in $modpath/tests/* 619s + echo /usr/lib/python3/dist-packages/pandas/tests/extension 619s + grep -q -e __pycache__ 619s + PANDAS_CI=1 619s + LC_ALL=C.UTF-8 619s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.gY8OYq/build.DBr/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/extension 620s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 620s 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" 620s 620s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 625s ============================= test session starts ============================== 625s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 625s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 625s rootdir: /usr/lib/python3/dist-packages/pandas 625s configfile: ../../../../../tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml 625s plugins: typeguard-4.4.2, hypothesis-6.127.4, asyncio-0.25.1, forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, qt-4.4.0 625s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 625s collected 16808 items / 1 skipped 625s 625s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/array_with_attr/test_array_with_attr.py . 632s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/decimal/test_decimal.py ssssssssssssssssssssssssssssssssssss....................................x.................................................................................................................................................................................................................................................................................................................................xx............................................................s............................xxxxxxxxss..............xxssxxss................................................xxx..................... 651s ../../../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. 651s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/list/test_list.py . 653s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/test_categorical.py ssssssssssssssssssssssssssssssssssss....................................x..................................................................................................ssssssssssssssssssssssss...................................s.........................................................................................................................ss.................................................................................................xx...........................................................s............x..sxx................x.............xxxxxssssssssssssssssssssssssssssssssssss.. 653s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/test_common.py ............ 656s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/test_datetime.py ........................ssss............................................x..............................................................................................ssssssssssssssssssssssss.................................................................s......................................................................................................................................................................................xx..............................................xx...........................................................s............................................ssss......... 656s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/test_extension.py .............. 659s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/test_interval.py ssssssssssssssssssssssssssssssssssss....................................x..................................................................................................ssssssssssssssssssssssss.................................................................s...............................................................................................................................ss......................................................xx..............................................xx............................................................s............x. 686s ../../../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 694s ../../../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.. 698s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/test_period.py ..........................................ssss........ssss.....................................................................................x...x..................................................................................................................................................................................................ssssssssssssssssssssssssssssssssssssssssssssssss..................................................................................................................................ss........................................................................................................................................................................................................................................................................................................................................................................................................................................................................xxxx.......................................................................................................................s.s............................................................................ssss........ssss................ 714s ../../../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. 721s ../../../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 721s 721s =============================== warnings summary =============================== 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-smw0uuhs' 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-rpupcr4p' 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.gY8OYq/autopkgtest_tmp/test-data.xml --- 721s ============================= slowest 30 durations ============================= 721s 0.43s call tests/extension/decimal/test_decimal.py::TestDecimalArray::test_arith_series_with_array[__rpow__] 721s 0.42s call tests/extension/decimal/test_decimal.py::TestDecimalArray::test_arith_frame_with_scalar[__rpow__] 721s 0.42s call tests/extension/decimal/test_decimal.py::TestDecimalArray::test_arith_series_with_scalar[__rpow__] 721s 0.41s call tests/extension/decimal/test_decimal.py::TestDecimalArray::test_arith_series_with_array[__pow__] 721s 0.37s call tests/extension/decimal/test_decimal.py::TestDecimalArray::test_arith_frame_with_scalar[__pow__] 721s 0.37s call tests/extension/decimal/test_decimal.py::TestDecimalArray::test_arith_series_with_scalar[__pow__] 721s 0.23s call tests/extension/test_masked.py::TestMaskedArrays::test_setitem_loc_scalar_mixed[Int16Dtype] 721s 0.16s call tests/extension/json/test_json.py::TestJSONArray::test_unary_ufunc_dunder_equivalence[negative] 721s 0.09s teardown tests/extension/test_string.py::test_searchsorted_with_na_raises[False-False-pyarrow_numpy] 721s 0.07s call tests/extension/test_sparse.py::TestSparseArray::test_unstack[0-series-index2] 721s 0.07s call tests/extension/test_numpy.py::TestNumpyExtensionArray::test_unstack[object-series-index2] 721s 0.07s call tests/extension/test_sparse.py::TestSparseArray::test_unstack[nan-series-index2] 721s 0.07s call tests/extension/test_sparse.py::TestSparseArray::test_unstack[0-series-index3] 721s 0.06s call tests/extension/test_sparse.py::TestSparseArray::test_unstack[nan-series-index3] 721s 0.06s call tests/extension/test_interval.py::TestIntervalArray::test_unstack[series-index2] 721s 0.06s call tests/extension/test_interval.py::TestIntervalArray::test_unstack[series-index3] 721s 0.06s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[Float32Dtype-series-index2] 721s 0.06s call tests/extension/test_string.py::TestStringArray::test_unstack[False-python-series-index2] 721s 0.06s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[UInt16Dtype-series-index3] 721s 0.06s call tests/extension/test_interval.py::TestIntervalArray::test_unstack[frame-index2] 721s 0.06s call tests/extension/test_string.py::TestStringArray::test_unstack[True-python-series-index2] 721s 0.06s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[Float32Dtype-series-index3] 721s 0.06s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[Float64Dtype-series-index2] 721s 0.06s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[BooleanDtype-series-index2] 721s 0.06s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[UInt64Dtype-series-index2] 721s 0.06s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[Float64Dtype-series-index3] 721s 0.06s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[UInt16Dtype-series-index2] 721s 0.06s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[Int32Dtype-series-index2] 721s 0.06s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[UInt32Dtype-series-index2] 721s 0.06s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[BooleanDtype-series-index3] 721s === 12106 passed, 4371 skipped, 332 xfailed, 2 warnings in 100.55s (0:01:40) === 723s rdjoqkol test state = true 723s + echo 'rdjoqkol test state = true' 723s + for TEST_SUBSET in $modpath/tests/* 723s + echo /usr/lib/python3/dist-packages/pandas/tests/frame 723s + grep -q -e __pycache__ 723s + PANDAS_CI=1 723s + LC_ALL=C.UTF-8 723s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.gY8OYq/build.DBr/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/frame 724s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 724s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 724s 724s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 731s ============================= test session starts ============================== 731s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 731s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 731s rootdir: /usr/lib/python3/dist-packages/pandas 731s configfile: ../../../../../tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml 731s plugins: typeguard-4.4.2, hypothesis-6.127.4, asyncio-0.25.1, forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, qt-4.4.0 731s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 731s collected 11172 items / 433 deselected / 1 skipped / 10739 selected 731s 731s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/constructors/test_from_dict.py .............. 731s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/constructors/test_from_records.py ........................... 731s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_coercion.py .......x.x. 731s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_delitem.py .... 731s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_get.py .... 731s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_get_value.py .. 731s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_getitem.py ........................................ 734s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_indexing.py ...................................................................................................................................................................................................................................sss................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................. 734s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_insert.py ....... 734s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_mask.py ........... 734s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_set_value.py ... 735s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_setitem.py ........................................................................................................s..........................................................................................xxx...........................x..x..x..x........ 735s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_take.py .... 738s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_where.py ............................................................................................................................................. 738s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_xs.py .............................. 738s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_add_prefix_suffix.py ... 740s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_align.py ........................................................................................................................................................................................................................................................................................................................................................................................................................ 740s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_asfreq.py ........................................ 740s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_asof.py ........... 740s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_assign.py ..... 741s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_astype.py .......................................................................................................................s....s........................................................................................................ss.....ssssssssss 741s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_at_time.py ...................... 741s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_between_time.py .............................. 741s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_clip.py ..................... 741s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_combine.py ..... 742s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_combine_first.py ..................................s............................... 742s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_compare.py ......................... 742s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_convert_dtypes.py ..ssss..ssss.sss.. 742s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_copy.py ..... 742s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_count.py .. 743s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_cov_corr.py .............................................................s............ 743s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_describe.py ...............................................s 743s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_diff.py .............................................. 743s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_dot.py ................sss 744s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_drop.py ......................................................................... 744s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_drop_duplicates.py ..................................... 744s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_droplevel.py .. 744s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_dropna.py ................... 744s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_dtypes.py ........ 744s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_duplicated.py .......xxx........... 744s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_equals.py ... 744s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_explode.py ..................... 745s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_fillna.py ................................................................. 745s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_filter.py ........... 745s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_first_and_last.py ............. 745s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_first_valid_index.py ............... 745s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_get_numeric_data.py .... 746s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_head_tail.py .................................................................. 746s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_infer_objects.py . 747s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_info.py ..........................x....x.s...... 747s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_interpolate.py ...................................................................ssssssssss 747s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_is_homogeneous_dtype.py ....... 747s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_isetitem.py ... 747s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_isin.py ................. 747s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_iterrows.py . 748s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_join.py ...........s................... 748s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_map.py ......................... 748s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_matmul.py .. 748s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_nlargest.py .........................................................................................................................................................................................................................................................X.....X.....X.....X.......X..... 749s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_pct_change.py ............................. 749s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_pipe.py ...... 749s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_pop.py ... 752s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_quantile.py ........................................................................xx..........xx..........xx..........xx.................. 755s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_rank.py .........................................................................................................................ss 756s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_reindex.py ......x.......................................................................................................................................... 756s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_reindex_like.py ..... 756s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_rename.py ......................... 756s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_rename_axis.py ......... 756s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_reorder_levels.py ... 757s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_replace.py ...................ss.................ssss....ssss................................................................................................................................................................. 757s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_reset_index.py ................................................................................................................................ 757s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_round.py ......... 757s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_sample.py .......................................................... 757s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_select_dtypes.py ..................................s...... 758s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_set_axis.py .............. 760s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_set_index.py ................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................. 764s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_shift.py ...................................................................................x.x.x.x.x.xxxx........ 764s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_size.py ..... 765s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_sort_index.py ................................................................. 765s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_sort_values.py ...................................................X...............................XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX..... 765s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_swapaxes.py .... 765s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_swaplevel.py . 768s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_to_csv.py ............................................................................. 768s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_to_dict.py ...................................................................................................... 768s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_to_dict_of_blocks.py ... 768s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_to_numpy.py .... 768s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_to_period.py ...................................................................... 768s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_to_records.py ................................... 768s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_to_timestamp.py ...................................................................... 769s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_transpose.py ................... 769s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_truncate.py ........................................................................................ 769s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_tz_convert.py ........... 769s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_tz_localize.py ......... 769s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_update.py .............. 769s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_value_counts.py ................................. 769s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_values.py ............... 769s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_alter_axes.py .. 770s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_api.py ......................ss.......... 773s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_arithmetic.py ..........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................x..........x................................................................................................................................ 773s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_block_internals.py ................... 776s ../../../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................................ 776s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_cumulative.py ....... 777s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_iteration.py .................... 777s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_logical_ops.py ................. 777s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_nonunique_indexes.py ................ 777s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_npfuncs.py .... 779s ../../../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. 784s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_reductions.py ....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................s....................................................................................................x.............x............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................. 785s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_repr.py ..........................................ssss................ 793s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_stack_unstack.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 793s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_subclass.py .................................................... 795s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_ufunc.py ....xx.........xxxxxxxx.xx....s. 795s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_unary.py .................. 795s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_validate.py ............................ 795s 795s =============================== warnings summary =============================== 795s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 795s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-pm06xv93' 795s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 795s 795s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 795s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-8fnwyrhq' 795s session.config.cache.set(STEPWISE_CACHE_DIR, []) 795s 795s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 795s -- generated xml file: /tmp/autopkgtest.gY8OYq/autopkgtest_tmp/test-data.xml --- 795s ============================= slowest 30 durations ============================= 795s 2.12s call tests/frame/methods/test_rank.py::TestRank::test_pct_max_many_rows 795s 2.11s call tests/frame/indexing/test_where.py::test_where_inplace_casting 795s 0.82s call tests/frame/test_api.py::TestDataFrameMisc::test_inspect_getmembers 795s 0.54s call tests/frame/methods/test_to_csv.py::TestDataFrameToCSV::test_to_csv_chunking[10000] 795s 0.53s call tests/frame/methods/test_to_csv.py::TestDataFrameToCSV::test_to_csv_chunking[50000] 795s 0.52s call tests/frame/methods/test_to_csv.py::TestDataFrameToCSV::test_to_csv_chunking[100000] 795s 0.48s call tests/frame/methods/test_cov_corr.py::TestDataFrameCorr::test_corr_scipy_method[kendall] 795s 0.37s call tests/frame/methods/test_to_csv.py::TestDataFrameToCSV::test_to_csv_with_dst_transitions_with_pickle 795s 0.32s 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] 795s 0.30s call tests/frame/test_reductions.py::test_minmax_extensionarray[min-False] 795s 0.26s call tests/frame/methods/test_info.py::test_info_verbose_check_header_separator_body 795s 0.19s call tests/frame/methods/test_cov_corr.py::TestDataFrameCorrWith::test_corrwith[Float64] 795s 0.17s call tests/frame/methods/test_to_csv.py::TestDataFrameToCSV::test_to_csv_dups_cols 795s 0.17s call tests/frame/methods/test_at_time.py::TestAtTime::test_at_time_axis[0] 795s 0.16s call tests/frame/test_stack_unstack.py::TestStackUnstackMultiLevel::test_stack_order_with_unsorted_levels_multi_row[False] 795s 0.16s call tests/frame/test_stack_unstack.py::TestStackUnstackMultiLevel::test_stack[False] 795s 0.16s call tests/frame/methods/test_at_time.py::TestAtTime::test_at_time_axis[index] 795s 0.13s call tests/frame/test_stack_unstack.py::TestStackUnstackMultiLevel::test_stack[True] 795s 0.11s call tests/frame/test_stack_unstack.py::TestStackUnstackMultiLevel::test_stack_order_with_unsorted_levels_multi_row[True] 795s 0.11s call tests/frame/test_repr.py::TestDataFrameRepr::test_repr_to_string 795s 0.11s call tests/frame/test_repr.py::TestDataFrameRepr::test_repr_bytes_61_lines 795s 0.09s call tests/frame/test_stack_unstack.py::TestStackUnstackMultiLevel::test_stack_unstack_multiple[False] 795s 0.09s call tests/frame/methods/test_interpolate.py::TestDataFrameInterpolate::test_interp_string_axis[index-0] 795s 0.08s call tests/frame/test_stack_unstack.py::TestStackUnstackMultiLevel::test_stack_unstack_multiple[True] 795s 0.08s call tests/frame/test_query_eval.py::TestDataFrameQueryNumExprPandas::test_nested_scope 795s 0.07s call tests/frame/test_stack_unstack.py::TestDataFrameReshape::test_stack_int_level_names[False] 795s 0.07s call tests/frame/methods/test_interpolate.py::TestDataFrameInterpolate::test_interp_string_axis[columns-1] 795s 0.07s call tests/frame/test_block_internals.py::TestDataFrameBlockInternals::test_strange_column_corruption_issue 795s 0.06s teardown tests/frame/test_validate.py::TestDataFrameValidate::test_validate_bool_args[5.0-sort_values] 795s 0.06s call tests/frame/methods/test_to_csv.py::TestDataFrameToCSV::test_to_csv_multiindex 795s = 10436 passed, 206 skipped, 433 deselected, 60 xfailed, 38 xpassed, 2 warnings in 71.39s (0:01:11) = 797s + echo 'rdjoqkol test state = true' 797s + for TEST_SUBSET in $modpath/tests/* 797s + echo /usr/lib/python3/dist-packages/pandas/tests/generic 797s + grep -q -e __pycache__ 797s rdjoqkol test state = true 797s + PANDAS_CI=1 797s + LC_ALL=C.UTF-8 797s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.gY8OYq/build.DBr/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/generic 798s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 798s 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" 798s 798s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 799s ============================= test session starts ============================== 799s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 799s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 799s rootdir: /usr/lib/python3/dist-packages/pandas 799s configfile: ../../../../../tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml 799s plugins: typeguard-4.4.2, hypothesis-6.127.4, asyncio-0.25.1, forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, qt-4.4.0 799s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 799s collected 1249 items 799s 799s ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_duplicate_labels.py ..........xx...........x.......xx.xxx................x................ 805s ../../../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. 805s ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_frame.py ............... 805s ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_generic.py ................................................................................. 805s ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_label_or_level_utils.py ....................................................................... 805s ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_series.py ................... 806s ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py expected 806s bar a b c d e f g h 806s foo 806s pandas_0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 806s pandas_1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 806s pandas_2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 806s pandas_3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 806s Index(['pandas_0', 'pandas_1', 'pandas_2', 'pandas_3'], dtype='object', name='foo') 806s bar 806s a object 806s b int64 806s c uint8 806s d float64 806s e bool 806s f category 806s g datetime64[ns] 806s h datetime64[ns, US/Eastern] 806s dtype: object 806s actual 806s Size: 172B 806s Dimensions: (foo: 4) 806s Coordinates: 806s * foo (foo) object 16B 'pandas_0' 'pandas_1' 'pandas_2' 'pandas_3' 806s Data variables: 806s a (foo) object 16B 'a' 'b' 'c' 'd' 806s b (foo) int64 32B 1 2 3 4 806s c (foo) uint8 4B 3 4 5 6 806s d (foo) float64 32B 4.0 5.0 6.0 7.0 806s e (foo) bool 4B True False True False 806s f (foo) category 20B Size: 188B 806s Dimensions: (foo: 4) 806s Coordinates: 806s * foo (foo) datetime64[ns] 32B 2020-01-01 2020-01-02 ... 2020-01-04 806s Data variables: 806s a (foo) object 16B 'a' 'b' 'c' 'd' 806s b (foo) int64 32B 1 2 3 4 806s c (foo) uint8 4B 3 4 5 6 806s d (foo) float64 32B 4.0 5.0 6.0 7.0 806s e (foo) bool 4B True False True False 806s f (foo) category 20B Size: 172B 806s Dimensions: (foo: 4) 806s Coordinates: 806s * foo (foo) object 16B 1577865600000000000 ... 1578124800000000000 806s Data variables: 806s a (foo) object 16B 'a' 'b' 'c' 'd' 806s b (foo) int64 32B 1 2 3 4 806s c (foo) uint8 4B 3 4 5 6 806s d (foo) float64 32B 4.0 5.0 6.0 7.0 806s e (foo) bool 4B True False True False 806s f (foo) category 20B Size: 172B 806s Dimensions: (foo: 4) 806s Coordinates: 806s * foo (foo) object 16B 2020-01-01 2020-01-02 2020-01-03 2020-01-04 806s Data variables: 806s a (foo) object 16B 'a' 'b' 'c' 'd' 806s b (foo) int64 32B 1 2 3 4 806s c (foo) uint8 4B 3 4 5 6 806s d (foo) float64 32B 4.0 5.0 6.0 7.0 806s e (foo) bool 4B True False True False 806s f (foo) category 20B Size: 188B 806s Dimensions: (foo: 4) 806s Coordinates: 806s * foo (foo) timedelta64[ns] 32B 1 days 2 days 3 days 4 days 806s Data variables: 806s a (foo) object 16B 'a' 'b' 'c' 'd' 806s b (foo) int64 32B 1 2 3 4 806s c (foo) uint8 4B 3 4 5 6 806s d (foo) float64 32B 4.0 5.0 6.0 7.0 806s e (foo) bool 4B True False True False 806s f (foo) category 20B Size: 188B 806s Dimensions: (foo: 4) 806s Coordinates: 806s * foo (foo) int64 32B 0 1 2 3 806s Data variables: 806s a (foo) object 16B 'a' 'b' 'c' 'd' 806s b (foo) int64 32B 1 2 3 4 806s c (foo) uint8 4B 3 4 5 6 806s d (foo) float64 32B 4.0 5.0 6.0 7.0 806s e (foo) bool 4B True False True False 806s f (foo) category 20B Size: 160B 806s Dimensions: (foo: 4) 806s Coordinates: 806s * foo (foo) int8 4B 0 1 2 3 806s Data variables: 806s a (foo) object 16B 'a' 'b' 'c' 'd' 806s b (foo) int64 32B 1 2 3 4 806s c (foo) uint8 4B 3 4 5 6 806s d (foo) float64 32B 4.0 5.0 6.0 7.0 806s e (foo) bool 4B True False True False 806s f (foo) category 20B Size: 164B 806s Dimensions: (foo: 4) 806s Coordinates: 806s * foo (foo) int16 8B 0 1 2 3 806s Data variables: 806s a (foo) object 16B 'a' 'b' 'c' 'd' 806s b (foo) int64 32B 1 2 3 4 806s c (foo) uint8 4B 3 4 5 6 806s d (foo) float64 32B 4.0 5.0 6.0 7.0 806s e (foo) bool 4B True False True False 806s f (foo) category 20B Size: 172B 806s Dimensions: (foo: 4) 806s Coordinates: 806s * foo (foo) int32 16B 0 1 2 3 806s Data variables: 806s a (foo) object 16B 'a' 'b' 'c' 'd' 806s b (foo) int64 32B 1 2 3 4 806s c (foo) uint8 4B 3 4 5 6 806s d (foo) float64 32B 4.0 5.0 6.0 7.0 806s e (foo) bool 4B True False True False 806s f (foo) category 20B Size: 188B 806s Dimensions: (foo: 4) 806s Coordinates: 806s * foo (foo) int64 32B 0 1 2 3 806s Data variables: 806s a (foo) object 16B 'a' 'b' 'c' 'd' 806s b (foo) int64 32B 1 2 3 4 806s c (foo) uint8 4B 3 4 5 6 806s d (foo) float64 32B 4.0 5.0 6.0 7.0 806s e (foo) bool 4B True False True False 806s f (foo) category 20B Size: 160B 806s Dimensions: (foo: 4) 806s Coordinates: 806s * foo (foo) uint8 4B 0 1 2 3 806s Data variables: 806s a (foo) object 16B 'a' 'b' 'c' 'd' 806s b (foo) int64 32B 1 2 3 4 806s c (foo) uint8 4B 3 4 5 6 806s d (foo) float64 32B 4.0 5.0 6.0 7.0 806s e (foo) bool 4B True False True False 806s f (foo) category 20B Size: 164B 806s Dimensions: (foo: 4) 806s Coordinates: 806s * foo (foo) uint16 8B 0 1 2 3 806s Data variables: 806s a (foo) object 16B 'a' 'b' 'c' 'd' 806s b (foo) int64 32B 1 2 3 4 806s c (foo) uint8 4B 3 4 5 6 806s d (foo) float64 32B 4.0 5.0 6.0 7.0 806s e (foo) bool 4B True False True False 806s f (foo) category 20B Size: 172B 806s Dimensions: (foo: 4) 806s Coordinates: 806s * foo (foo) uint32 16B 0 1 2 3 806s Data variables: 806s a (foo) object 16B 'a' 'b' 'c' 'd' 806s b (foo) int64 32B 1 2 3 4 806s c (foo) uint8 4B 3 4 5 6 806s d (foo) float64 32B 4.0 5.0 6.0 7.0 806s e (foo) bool 4B True False True False 806s f (foo) category 20B Size: 188B 806s Dimensions: (foo: 4) 806s Coordinates: 806s * foo (foo) uint64 32B 0 1 2 3 806s Data variables: 806s a (foo) object 16B 'a' 'b' 'c' 'd' 806s b (foo) int64 32B 1 2 3 4 806s c (foo) uint8 4B 3 4 5 6 806s d (foo) float64 32B 4.0 5.0 6.0 7.0 806s e (foo) bool 4B True False True False 806s f (foo) category 20B Size: 172B 806s Dimensions: (foo: 4) 806s Coordinates: 806s * foo (foo) float32 16B 0.0 1.0 2.0 3.0 806s Data variables: 806s a (foo) object 16B 'a' 'b' 'c' 'd' 806s b (foo) int64 32B 1 2 3 4 806s c (foo) uint8 4B 3 4 5 6 806s d (foo) float64 32B 4.0 5.0 6.0 7.0 806s e (foo) bool 4B True False True False 806s f (foo) category 20B Size: 188B 806s Dimensions: (foo: 4) 806s Coordinates: 806s * foo (foo) float64 32B 0.0 1.0 2.0 3.0 806s Data variables: 806s a (foo) object 16B 'a' 'b' 'c' 'd' 806s b (foo) int64 32B 1 2 3 4 806s c (foo) uint8 4B 3 4 5 6 806s d (foo) float64 32B 4.0 5.0 6.0 7.0 806s e (foo) bool 4B True False True False 806s f (foo) category 20B Size: 172B 806s Dimensions: (foo: 4) 806s Coordinates: 806s * foo (foo) object 16B True False True False 806s Data variables: 806s a (foo) object 16B 'a' 'b' 'c' 'd' 806s b (foo) int64 32B 1 2 3 4 806s c (foo) uint8 4B 3 4 5 6 806s d (foo) float64 32B 4.0 5.0 6.0 7.0 806s e (foo) bool 4B True False True False 806s f (foo) category 20B Size: 160B 806s Dimensions: (foo: 4) 806s Coordinates: 806s * foo (foo) bool 4B True False True False 806s Data variables: 806s a (foo) object 16B 'a' 'b' 'c' 'd' 806s b (foo) int64 32B 1 2 3 4 806s c (foo) uint8 4B 3 4 5 6 806s d (foo) float64 32B 4.0 5.0 6.0 7.0 806s e (foo) bool 4B True False True False 806s f (foo) category 20B Size: 188B 806s Dimensions: (foo: 4) 806s Coordinates: 806s * foo (foo) complex64 32B 0j (1+1j) (2+2j) (3+3j) 806s Data variables: 806s a (foo) object 16B 'a' 'b' 'c' 'd' 806s b (foo) int64 32B 1 2 3 4 806s c (foo) uint8 4B 3 4 5 6 806s d (foo) float64 32B 4.0 5.0 6.0 7.0 806s e (foo) bool 4B True False True False 806s f (foo) category 20B Size: 220B 806s Dimensions: (foo: 4) 806s Coordinates: 806s * foo (foo) complex128 64B 0j (1+1j) (2+2j) (3+3j) 806s Data variables: 806s a (foo) object 16B 'a' 'b' 'c' 'd' 806s b (foo) int64 32B 1 2 3 4 806s c (foo) uint8 4B 3 4 5 6 806s d (foo) float64 32B 4.0 5.0 6.0 7.0 806s e (foo) bool 4B True False True False 806s f (foo) category 20B Size: 172B 806s Dimensions: (foo: 4) 806s Coordinates: 806s * foo (foo) object 16B 'a' 'b' 'c' 'd' 806s Data variables: 806s a (foo) object 16B 'a' 'b' 'c' 'd' 806s b (foo) int64 32B 1 2 3 4 806s c (foo) uint8 4B 3 4 5 6 806s d (foo) float64 32B 4.0 5.0 6.0 7.0 806s e (foo) bool 4B True False True False 806s f (foo) category 20B Size: 172B 806s Dimensions: (foo: 4) 806s Coordinates: 806s * foo (foo) object 16B (0.0, 1.0] (1.0, 2.0] (2.0, 3.0] (3.0, 4.0] 806s Data variables: 806s a (foo) object 16B 'a' 'b' 'c' 'd' 806s b (foo) int64 32B 1 2 3 4 806s c (foo) uint8 4B 3 4 5 6 806s d (foo) float64 32B 4.0 5.0 6.0 7.0 806s e (foo) bool 4B True False True False 806s f (foo) category 20B Size: 188B 806s Dimensions: (foo: 4) 806s Coordinates: 806s * foo (foo) int64 32B 0 0 1 1 806s Data variables: 806s a (foo) object 16B 'a' 'b' 'c' 'd' 806s b (foo) int64 32B 1 2 3 4 806s c (foo) uint8 4B 3 4 5 6 806s d (foo) float64 32B 4.0 5.0 6.0 7.0 806s e (foo) bool 4B True False True False 806s f (foo) category 20B Size: 172B 807s Dimensions: (foo: 4) 807s Coordinates: 807s * foo (foo) object 16B 0 1 2 3 807s Data variables: 807s a (foo) object 16B 'a' 'b' 'c' 'd' 807s b (foo) int64 32B 1 2 3 4 807s c (foo) uint8 4B 3 4 5 6 807s d (foo) float64 32B 4.0 5.0 6.0 7.0 807s e (foo) bool 4B True False True False 807s f (foo) category 20B Size: 172B 807s Dimensions: (foo: 4) 807s Coordinates: 807s * foo (foo) object 16B 0 1 2 3 807s Data variables: 807s a (foo) object 16B 'a' 'b' 'c' 'd' 807s b (foo) int64 32B 1 2 3 4 807s c (foo) uint8 4B 3 4 5 6 807s d (foo) float64 32B 4.0 5.0 6.0 7.0 807s e (foo) bool 4B True False True False 807s f (foo) category 20B Size: 172B 807s Dimensions: (foo: 4) 807s Coordinates: 807s * foo (foo) object 16B 0.0 1.0 2.0 3.0 807s Data variables: 807s a (foo) object 16B 'a' 'b' 'c' 'd' 807s b (foo) int64 32B 1 2 3 4 807s c (foo) uint8 4B 3 4 5 6 807s d (foo) float64 32B 4.0 5.0 6.0 7.0 807s e (foo) bool 4B True False True False 807s f (foo) category 20B Size: 172B 807s Dimensions: (foo: 4) 807s Coordinates: 807s * foo (foo) object 16B False True True True 807s Data variables: 807s a (foo) object 16B 'a' 'b' 'c' 'd' 807s b (foo) int64 32B 1 2 3 4 807s c (foo) uint8 4B 3 4 5 6 807s d (foo) float64 32B 4.0 5.0 6.0 7.0 807s e (foo) bool 4B True False True False 807s f (foo) category 20B Size: 172B 807s Dimensions: (foo: 4) 807s Coordinates: 807s * foo (foo) object 16B 'pandas_0' 'pandas_1' 'pandas_2' 'pandas_3' 807s Data variables: 807s a (foo) object 16B 'a' 'b' 'c' 'd' 807s b (foo) int64 32B 1 2 3 4 807s c (foo) uint8 4B 3 4 5 6 807s d (foo) float64 32B 4.0 5.0 6.0 7.0 807s e (foo) bool 4B True False True False 807s f (foo) category 20B 4] 1063s 0.01s call tests/interchange/test_impl.py::test_dataframe[3] 1063s 0.01s call tests/interchange/test_impl.py::test_dataframe[0] 1063s 0.01s call tests/interchange/test_impl.py::test_dataframe[1] 1063s 0.01s call tests/interchange/test_impl.py::test_dataframe[2] 1063s 0.01s call tests/interchange/test_impl.py::test_categorical_dtype[data0] 1063s 1063s (24 durations < 0.005s hidden. Use -vv to show these durations.) 1063s ================== 61 passed, 79 skipped, 2 warnings in 0.51s ================== 1063s rdjoqkol test state = true 1063s + echo 'rdjoqkol test state = true' 1063s + for TEST_SUBSET in $modpath/tests/* 1063s + echo /usr/lib/python3/dist-packages/pandas/tests/internals 1063s + grep -q -e __pycache__ 1063s + PANDAS_CI=1 1063s + LC_ALL=C.UTF-8 1063s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.gY8OYq/build.DBr/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/internals 1064s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1064s 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" 1064s 1064s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1064s ============================= test session starts ============================== 1064s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1064s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1064s rootdir: /usr/lib/python3/dist-packages/pandas 1064s configfile: ../../../../../tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml 1064s plugins: typeguard-4.4.2, hypothesis-6.127.4, asyncio-0.25.1, forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, qt-4.4.0 1064s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1064s collected 257 items 1064s 1064s ../../../usr/lib/python3/dist-packages/pandas/tests/internals/test_api.py ......... 1065s ../../../usr/lib/python3/dist-packages/pandas/tests/internals/test_internals.py .................................................................................................................................................................................................................................................... 1066s ../../../usr/lib/python3/dist-packages/pandas/tests/internals/test_managers.py .... 1066s 1066s =============================== warnings summary =============================== 1066s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1066s /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-6u2j90k9' 1066s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1066s 1066s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1066s /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-ew9y6i00' 1066s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1066s 1066s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1066s -- generated xml file: /tmp/autopkgtest.gY8OYq/autopkgtest_tmp/test-data.xml --- 1066s ============================= slowest 30 durations ============================= 1066s 0.45s call tests/internals/test_managers.py::test_array_manager_depr_env_var[array] 1066s 0.45s call tests/internals/test_managers.py::test_array_manager_depr_env_var[block] 1066s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[1-int64] 1066s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_equals_block_order_different_dtypes[c:sparse;d:sparse_na;b:f8] 1066s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[4-int64] 1066s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[4-float64] 1066s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[4-uint64] 1066s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[3-int64] 1066s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_interleave_dtype[a: category-i8] 1066s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[3-float64] 1066s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[5-int64] 1066s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[5-uint64] 1066s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_interleave_dtype[a: category2-object] 1066s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[5-float64] 1066s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_equals_block_order_different_dtypes[a:i8;e:dt;f:td;g:string] 1066s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[3-uint64] 1066s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_interleave_dtype[a: category2; b: category2-object] 1066s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_interleave_dtype[a: category; b: category-i8] 1066s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_interleave_dtype[a: category; b: category2-object] 1066s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[1-float64] 1066s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_interleave_dtype[a: f8; b: category-object] 1066s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_interleave_dtype[a: complex-complex] 1066s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_interleave_dtype[a: f4; b: i8; d: object-object] 1066s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_interleave_dtype[a: f4; b: i8-f8] 1066s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_interleave_dtype[a: M8[ns]; b: m8[ns]-object] 1066s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_interleave_dtype[a: f8-f8] 1066s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[1-uint64] 1066s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_interleave_dtype[a: M8[ns]; b: category-object] 1066s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_interleave_dtype[a: M8[ns]; b: bool-object] 1066s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_interleave_dtype[a: m8[ns]; b: i8-object] 1066s ======================= 257 passed, 2 warnings in 2.00s ======================== 1066s rdjoqkol test state = true 1066s + echo 'rdjoqkol test state = true' 1066s + for TEST_SUBSET in $modpath/tests/* 1066s + echo /usr/lib/python3/dist-packages/pandas/tests/io 1066s + grep -q -e __pycache__ 1066s + PANDAS_CI=1 1066s + LC_ALL=C.UTF-8 1066s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.gY8OYq/build.DBr/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/io 1067s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1067s 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" 1067s 1067s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1076s ============================= test session starts ============================== 1076s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1076s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1076s rootdir: /usr/lib/python3/dist-packages/pandas 1076s configfile: ../../../../../tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml 1076s plugins: typeguard-4.4.2, hypothesis-6.127.4, asyncio-0.25.1, forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, qt-4.4.0 1076s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1076s collected 15519 items / 201 deselected / 2 skipped / 15318 selected 1076s 1076s ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_odf.py ..... 1076s ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_odswriter.py .......... 1077s ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_openpyxl.py ...................................................... 1092s ../../../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 1094s ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_style.py ...................................................................................................................................s 1109s ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_writers.py .......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 1109s ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_xlrd.py ....... 1109s ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_xlsxwriter.py ..... 1110s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_bar.py ..........................................................................................................................s 1110s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_exceptions.py ... 1110s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_format.py ......................................................................................................... 1110s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_highlight.py ................................................................................................ 1111s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_html.py ........................................................................................... 1111s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_matplotlib.py ........................................................... 1111s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_non_unique.py ......... 1112s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_style.py ................................................................................................................................................................................................. 1113s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_to_latex.py ............................................................................................................................................................ 1113s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_to_string.py ..... 1113s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_tooltip.py .... 1113s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_console.py ........... 1113s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_css.py ............................................................................................... 1113s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_eng_formatting.py ....... 1114s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_format.py .................................................................................................................................................................................. 1114s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_ipython_compat.py ss..s 1114s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_printing.py ......... 1115s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_to_csv.py ..........s.................................................................................. 1115s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_to_excel.py .......................................................................................................................................................................................................................................................................................................................................................................................................................... 1117s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_to_html.py .....................................................................................................................................................................................................................................................................................................................................................................s................... 1117s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_to_latex.py ............................................................................................ 1117s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_to_markdown.py .......... 1117s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_to_string.py ...............................................s........................................... 1118s ../../../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....... 1118s ../../../usr/lib/python3/dist-packages/pandas/tests/io/json/test_deprecated_kwargs.py . 1119s ../../../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........................... 1119s ../../../usr/lib/python3/dist-packages/pandas/tests/io/json/test_json_table_schema_ext_dtype.py ..................... 1119s ../../../usr/lib/python3/dist-packages/pandas/tests/io/json/test_normalize.py ..................................................... 1123s ../../../usr/lib/python3/dist-packages/pandas/tests/io/json/test_pandas.py ...........................................................................................................xxxx................................xxx..............................ssssss....................................................................................................................................s........xxxxxxxxxxxxxxxxxx................................................................xx.............s.....x........ssssssssssssssssssssssssssssssss...sssss.s. 1123s ../../../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........... 1124s ../../../usr/lib/python3/dist-packages/pandas/tests/io/json/test_ujson.py s........................................................................................................................s....s.................................................................................... 1125s ../../../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 1125s ../../../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 1125s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_data_list.py ...s...s...s...s 1126s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_decimal.py ......ss...s 1127s ../../../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 1128s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_float.py ...s.......s.....................sss....x.....x...ss 1128s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_index.py ......ss......ss...s............ssss...s...s...s...s...s...s...s 1128s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_inf.py ......ss......ss...s 1128s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_ints.py ...s............ssss...s......ss...s.........sss.........sss......ss......ss...s 1128s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_iterator.py ...s...s...s.........sss...s 1128s ../../../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 1128s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_verbose.py ...s...s 1129s ../../../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 1132s ../../../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 1132s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/dtypes/test_empty.py ...s...s...s...s...s...s...s...s........................ssssssss 1132s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_c_parser_only.py .......................................................................... 1132s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_comment.py ......ss.........sss...s...s...s..................ssssss......ssxx.s 1135s ../../../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 1135s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_concatenate_chunks.py ss 1135s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_converters.py ...s............ssss...s...s...s......ss...s...s 1135s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_dialect.py ...s...s...s......................................................ssssssssssssssssss..................ssssss 1136s ../../../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 1137s ../../../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 1138s ../../../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 1138s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_mangle_dupes.py ...s...s...s.........sss.........sss...s...s...s......ss 1138s ../../../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 1145s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_network.py ................ssss.....ssssssssssssssssss 1147s ../../../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 1147s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_python_parser_only.py ..................................................................................... 1147s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_quoting.py .........sss......ss...s..................ssssss............ssss...............sssss......ss......ss......ss 1147s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_read_fwf.py ..........................................................................sss.. 1148s ../../../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 1148s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_textreader.py ..................................... 1148s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_unsupported.py ..........s...s..xs...s 1148s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_upcast.py ...........................ssss 1148s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/usecols/test_parse_dates.py ......ss...s...s...s............ssss 1148s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/usecols/test_strings.py ...s...s......ss......ss 1149s ../../../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 1150s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_append.py ....x................ 1151s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_categorical.py ..... 1151s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_compat.py .... 1152s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_complex.py ......... 1152s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_errors.py ................ 1157s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py ...................................................xxxxxxxxx..............................................................................................................xxxxxxxxxxxxxxxxxxx.. 1157s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_keys.py .... 1158s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_put.py ...................... 1158s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_pytables_missing.py s 1158s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_read.py ....................s 1159s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_retain_attributes.py ..... 1160s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_round_trip.py ..............................s 1164s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_select.py ...x.....x............... 1167s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_store.py ............................................x..................... 1167s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_subclass.py .. 1167s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_time_series.py .... 1168s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_timezones.py .......................................................................... 1169s ../../../usr/lib/python3/dist-packages/pandas/tests/io/sas/test_byteswap.py .......... 1169s ../../../usr/lib/python3/dist-packages/pandas/tests/io/sas/test_sas.py ... 1169s ../../../usr/lib/python3/dist-packages/pandas/tests/io/sas/test_sas7bdat.py ....................... 1170s ../../../usr/lib/python3/dist-packages/pandas/tests/io/sas/test_xport.py ....... 1172s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_clipboard.py ......................................................................................................................................................................................................................................................................................................................................ssssss.. 1172s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_common.py .......................................................s....s........ss.......s.........s.......s......................................... 1174s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_compression.py ........................................................................................................................................ 1174s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_fsspec.py .........ssssssssss..........s 1174s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_gbq.py .. 1174s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_gcs.py ssssssssssssssssss. 1184s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_html.py .........ssssss...............................................................................................................................s.................... 1192s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py ...ss.......ss.......ss....ss 1192s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_parquet.py .ssss.ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss.ssssssss 1199s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_pickle.py ................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................. 1199s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_s3.py .ss 1199s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_spss.py .......s.. 1225s ../../../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................ 1233s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_stata.py ..............................................................................................................................................................................................................................................................................................................................................................................s.................................................................................................................................................................................................................................................... 1233s ../../../usr/lib/python3/dist-packages/pandas/tests/io/xml/test_to_xml.py ........................................................................s...............................................................ss 1238s ../../../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. 1238s ../../../usr/lib/python3/dist-packages/pandas/tests/io/xml/test_xml_dtypes.py .............................................. 1238s 1238s =============================== warnings summary =============================== 1238s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1238s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-w3v2_ldy' 1238s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1238s 1238s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1238s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-r9oev0rz' 1238s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1238s 1238s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1238s -- generated xml file: /tmp/autopkgtest.gY8OYq/autopkgtest_tmp/test-data.xml --- 1238s ============================= slowest 30 durations ============================= 1238s 1.44s call tests/io/test_html.py::TestReadHtml::test_banklist_url[bs4] 1238s 1.03s call tests/io/pytables/test_store.py::test_no_track_times 1238s 0.99s call tests/io/pytables/test_select.py::test_select_iterator_complete_8014 1238s 0.98s call tests/io/test_pickle.py::test_pickle_big_dataframe_compression[gzip-4] 1238s 0.98s call tests/io/test_pickle.py::test_pickle_big_dataframe_compression[gzip-5] 1238s 0.64s call tests/io/pytables/test_select.py::test_select_iterator_non_complete_8014 1238s 0.61s call tests/io/pytables/test_categorical.py::test_categorical 1238s 0.53s call tests/io/test_compression.py::test_with_missing_lzma_runtime 1238s 0.51s call tests/io/test_html.py::TestReadHtml::test_banklist_no_match[bs4] 1238s 0.50s teardown tests/io/test_http_headers.py::test_request_headers[None-gz_json_responder-read_json] 1238s 0.50s teardown tests/io/test_http_headers.py::test_request_headers[storage_options2-gz_json_responder-read_json] 1238s 0.50s teardown tests/io/test_http_headers.py::test_request_headers[storage_options2-json_responder-read_json] 1238s 0.50s teardown tests/io/test_html.py::TestReadHtml::test_multiple_matches[bs4] 1238s 0.50s teardown tests/io/test_http_headers.py::test_request_headers[None-gz_csv_responder-read_csv] 1238s 0.50s teardown tests/io/parser/test_network.py::test_compressed_urls[gzip-c-explicit] 1238s 0.50s teardown tests/io/parser/test_network.py::test_compressed_urls[zip-c-explicit] 1238s 0.50s teardown tests/io/test_http_headers.py::test_request_headers[storage_options2-stata_responder-read_stata] 1238s 0.50s teardown tests/io/parser/common/test_file_buffer_url.py::test_url[python] 1238s 0.50s teardown tests/io/test_http_headers.py::test_request_headers[None-json_responder-read_json] 1238s 0.50s teardown tests/io/test_http_headers.py::test_request_headers[storage_options1-json_responder-read_json] 1238s 0.50s teardown tests/io/test_http_headers.py::test_request_headers[storage_options2-gz_csv_responder-read_csv] 1238s 0.50s teardown tests/io/test_http_headers.py::test_request_headers[None-csv_responder-read_csv] 1238s 0.50s teardown tests/io/xml/test_xml.py::test_wrong_url[lxml] 1238s 0.50s teardown tests/io/parser/test_network.py::test_url_encoding_csv 1238s 0.50s teardown tests/io/test_http_headers.py::test_request_headers[storage_options1-gz_csv_responder-read_csv] 1238s 0.50s teardown tests/io/xml/test_xml.py::test_wrong_url[etree] 1238s 0.50s teardown tests/io/parser/test_network.py::test_compressed_urls[zip-c-infer] 1238s 0.50s teardown tests/io/test_html.py::TestReadHtml::test_python_docs_table[bs4] 1238s 0.50s teardown tests/io/test_http_headers.py::test_request_headers[storage_options2-csv_responder-read_csv] 1238s 0.50s teardown tests/io/test_http_headers.py::test_request_headers[storage_options2-pickle_respnder-read_pickle] 1238s = 12121 passed, 3025 skipped, 201 deselected, 174 xfailed, 2 warnings in 171.50s (0:02:51) = 1240s rdjoqkol test state = true 1240s + echo 'rdjoqkol test state = true' 1240s + for TEST_SUBSET in $modpath/tests/* 1240s + echo /usr/lib/python3/dist-packages/pandas/tests/libs 1240s + grep -q -e __pycache__ 1240s + PANDAS_CI=1 1240s + LC_ALL=C.UTF-8 1240s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.gY8OYq/build.DBr/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/libs 1241s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1241s 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" 1241s 1241s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1242s ============================= test session starts ============================== 1242s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1242s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1242s rootdir: /usr/lib/python3/dist-packages/pandas 1242s configfile: ../../../../../tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml 1242s plugins: typeguard-4.4.2, hypothesis-6.127.4, asyncio-0.25.1, forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, qt-4.4.0 1242s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1242s collected 2279 items 1242s 1245s ../../../usr/lib/python3/dist-packages/pandas/tests/libs/test_hashtable.py ..............s.....................................................................s.............s.......................................................s.............s.................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................s................................................................................................................................................................................................. 1245s ../../../usr/lib/python3/dist-packages/pandas/tests/libs/test_join.py ................. 1245s ../../../usr/lib/python3/dist-packages/pandas/tests/libs/test_lib.py ..........................................................................ss...... 1245s ../../../usr/lib/python3/dist-packages/pandas/tests/libs/test_libalgos.py ........ 1245s 1245s =============================== warnings summary =============================== 1245s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1245s /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-5oau1rrl' 1245s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1245s 1245s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1245s /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-g01024cw' 1245s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1245s 1245s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1245s -- generated xml file: /tmp/autopkgtest.gY8OYq/autopkgtest_tmp/test-data.xml --- 1245s ============================= slowest 30 durations ============================= 1245s 0.01s teardown tests/libs/test_libalgos.py::TestInfinity::test_infinity_against_nan 1245s 0.01s call tests/libs/test_hashtable.py::test_unique_label_indices 1245s 0.01s call tests/libs/test_libalgos.py::TestInfinity::test_infinity_sort 1245s 1245s (27 durations < 0.005s hidden. Use -vv to show these durations.) 1245s ================= 2271 passed, 8 skipped, 2 warnings in 3.40s ================== 1245s rdjoqkol test state = true 1245s + echo 'rdjoqkol test state = true' 1245s + for TEST_SUBSET in $modpath/tests/* 1245s + echo /usr/lib/python3/dist-packages/pandas/tests/plotting 1245s + grep -q -e __pycache__ 1245s + PANDAS_CI=1 1245s + LC_ALL=C.UTF-8 1245s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.gY8OYq/build.DBr/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/plotting 1246s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1246s 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" 1246s 1246s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1248s ============================= test session starts ============================== 1248s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1248s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1248s rootdir: /usr/lib/python3/dist-packages/pandas 1248s configfile: ../../../../../tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml 1248s plugins: typeguard-4.4.2, hypothesis-6.127.4, asyncio-0.25.1, forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, qt-4.4.0 1248s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1248s collected 1423 items / 212 deselected / 1211 selected 1248s 1268s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/frame/test_frame.py ..................................................XX.........................s.s.s.s....................................................................................................x...................................................................................... 1273s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/frame/test_frame_color.py ......................................................................................... 1274s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/frame/test_frame_groupby.py ...... 1275s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/frame/test_frame_legend.py x..................... 1282s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/frame/test_frame_subplots.py .........x....................XX................................................................... 1283s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/frame/test_hist_box_by.py ............................. 1283s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_backend.py .....s. 1287s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_boxplot_method.py .................................................... 1287s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_common.py ... 1288s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_converter.py ............................................ 1303s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_datetimelike.py ...............................................................................................................x..........................................x.......................x...............x..... 1304s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_groupby.py ................. 1309s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_hist_method.py ...........................x..x...................................................... 1316s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_misc.py s....................sss...................sss...................sss.................................. 1321s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_series.py ...............................XXXX.............................x........................................................x......................... 1321s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_style.py ...................................... 1321s 1321s =============================== warnings summary =============================== 1321s tests/plotting/frame/test_frame.py: 11 warnings 1321s /usr/lib/python3/dist-packages/matplotlib/transforms.py:2650: RuntimeWarning: divide by zero encountered in scalar divide 1321s x_scale = 1.0 / inw 1321s 1321s tests/plotting/frame/test_frame.py: 11 warnings 1321s /usr/lib/python3/dist-packages/matplotlib/transforms.py:2652: RuntimeWarning: invalid value encountered in scalar multiply 1321s self._mtx = np.array([[x_scale, 0.0, -inl*x_scale], 1321s 1321s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1321s /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-vit6h8wd' 1321s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1321s 1321s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1321s /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-zv4j87eq' 1321s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1321s 1321s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1321s -- generated xml file: /tmp/autopkgtest.gY8OYq/autopkgtest_tmp/test-data.xml --- 1321s ============================= slowest 30 durations ============================= 1321s 0.77s call tests/plotting/test_misc.py::TestDataFramePlots::test_scatter_matrix_axis_smaller[True] 1321s 0.70s call tests/plotting/test_datetimelike.py::TestTSPlot::test_finder_daily 1321s 0.70s call tests/plotting/test_converter.py::test_registry_mpl_resets 1321s 0.66s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_errorbar_timeseries[bar] 1321s 0.61s call tests/plotting/test_converter.py::TestRegistration::test_dont_register_by_default 1321s 0.57s call tests/plotting/test_misc.py::TestSeriesPlots::test_bootstrap_plot 1321s 0.50s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_errorbar_timeseries[barh] 1321s 0.50s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_sharex_and_ax 1321s 0.50s call tests/plotting/frame/test_frame_subplots.py::TestDataFramePlotsSubplots::test_subplots_ts_share_axes 1321s 0.49s call tests/plotting/test_misc.py::TestDataFramePlots::test_scatter_matrix_axis[True] 1321s 0.44s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_kde_df 1321s 0.40s call tests/plotting/test_misc.py::TestDataFramePlots::test_scatter_matrix_axis[False] 1321s 0.40s call tests/plotting/test_misc.py::TestDataFramePlots::test_scatter_matrix_axis_smaller[False] 1321s 0.40s call tests/plotting/test_boxplot_method.py::TestDataFrameGroupByPlots::test_boxplot_legacy3[False-None-1-layout1] 1321s 0.39s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_errorbar_timeseries[line] 1321s 0.36s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_sharey_and_ax 1321s 0.35s call tests/plotting/test_boxplot_method.py::TestDataFrameGroupByPlots::test_boxplot_legacy3[True-UserWarning-3-layout0] 1321s 0.35s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_df_gridspec_patterns_vert_horiz 1321s 0.34s call tests/plotting/test_hist_method.py::TestDataFrameGroupByPlots::test_histtype_argument[barstacked-True] 1321s 0.32s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_hist_df 1321s 0.30s call tests/plotting/frame/test_frame_subplots.py::TestDataFramePlotsSubplots::test_subplots_constrained_layout 1321s 0.30s call tests/plotting/test_datetimelike.py::TestTSPlot::test_line_plot_period_mlt_series[4D] 1321s 0.30s call tests/plotting/test_datetimelike.py::TestTSPlot::test_mixed_freq_second_millisecond 1321s 0.29s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_hist_df_coord[data0] 1321s 0.29s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_hist_df_coord[data1] 1321s 0.28s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_bar_bottom_left_subplots 1321s 0.27s call tests/plotting/test_boxplot_method.py::TestDataFramePlots::test_stacked_boxplot_set_axis 1321s 0.27s call tests/plotting/test_misc.py::test_savefig[index2-data0-hexbin] 1321s 0.27s call tests/plotting/test_misc.py::test_savefig[index0-data0-hexbin] 1321s 0.26s call tests/plotting/test_misc.py::test_savefig[index1-data0-hexbin] 1321s = 1177 passed, 15 skipped, 212 deselected, 11 xfailed, 8 xpassed, 24 warnings in 75.14s (0:01:15) = 1322s + echo 'rdjoqkol test state = true' 1322s + for TEST_SUBSET in $modpath/tests/* 1322s rdjoqkol test state = true 1322s + echo /usr/lib/python3/dist-packages/pandas/tests/reductions 1322s + grep -q -e __pycache__ 1322s + PANDAS_CI=1 1322s + LC_ALL=C.UTF-8 1322s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.gY8OYq/build.DBr/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/reductions 1323s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1323s 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" 1323s 1323s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1323s ============================= test session starts ============================== 1323s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1323s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1323s rootdir: /usr/lib/python3/dist-packages/pandas 1323s configfile: ../../../../../tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml 1323s plugins: typeguard-4.4.2, hypothesis-6.127.4, asyncio-0.25.1, forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, qt-4.4.0 1323s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1323s collected 550 items 1323s 1324s ../../../usr/lib/python3/dist-packages/pandas/tests/reductions/test_reductions.py .....................................................................................................................................................................................................................................................................................................................................s....................................................................................................................................... 1325s ../../../usr/lib/python3/dist-packages/pandas/tests/reductions/test_stat_reductions.py ......................................................................................... 1325s 1325s =============================== warnings summary =============================== 1325s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1325s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-2midsqim' 1325s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1325s 1325s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1325s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-xsgdfd4q' 1325s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1325s 1325s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1325s -- generated xml file: /tmp/autopkgtest.gY8OYq/autopkgtest_tmp/test-data.xml --- 1325s ============================= slowest 30 durations ============================= 1325s 0.42s call tests/reductions/test_stat_reductions.py::TestSeriesStatReductions::test_skew 1325s 0.05s call tests/reductions/test_reductions.py::TestReductions::test_same_tz_min_max_axis_1[max-a] 1325s 0.03s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_int[int32-True] 1325s 0.03s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_float[float64-True] 1325s 0.03s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_float[float64-False] 1325s 0.02s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_int[int32-False] 1325s 0.02s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_int[int64-True] 1325s 0.02s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_int[int64-False] 1325s 0.02s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_float[float32-False] 1325s 0.02s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_float[float32-True] 1325s 0.01s call tests/reductions/test_reductions.py::TestIndexReductions::test_timedelta_ops 1325s 0.01s call tests/reductions/test_stat_reductions.py::TestSeriesStatReductions::test_var_std 1325s 1325s (18 durations < 0.005s hidden. Use -vv to show these durations.) 1325s ================== 549 passed, 1 skipped, 2 warnings in 2.18s ================== 1325s rdjoqkol test state = true 1325s + echo 'rdjoqkol test state = true' 1325s + for TEST_SUBSET in $modpath/tests/* 1325s + echo /usr/lib/python3/dist-packages/pandas/tests/resample 1325s + grep -q -e __pycache__ 1325s + PANDAS_CI=1 1325s + LC_ALL=C.UTF-8 1325s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.gY8OYq/build.DBr/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/resample 1326s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1326s 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" 1326s 1326s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1327s ============================= test session starts ============================== 1327s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1327s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1327s rootdir: /usr/lib/python3/dist-packages/pandas 1327s configfile: ../../../../../tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml 1327s plugins: typeguard-4.4.2, hypothesis-6.127.4, asyncio-0.25.1, forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, qt-4.4.0 1327s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1327s collected 4179 items 1327s 1331s ../../../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............................................................................................................................................................................................................................................................................................................................................................................................................................................................. 1360s ../../../usr/lib/python3/dist-packages/pandas/tests/resample/test_datetime_index.py ................................................................................ssss............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................x...x...x...x..........................................................................................................................................................................................................................................................................................................................................................................ss 1361s ../../../usr/lib/python3/dist-packages/pandas/tests/resample/test_period_index.py .................................................................................................................................................................................................................................................................................................................................................................................................................................x.................................................................................. 1362s ../../../usr/lib/python3/dist-packages/pandas/tests/resample/test_resample_api.py ..................................................................................................................................................................................................... 1363s ../../../usr/lib/python3/dist-packages/pandas/tests/resample/test_resampler_grouper.py s................................................... 1363s ../../../usr/lib/python3/dist-packages/pandas/tests/resample/test_time_grouper.py .........................x...................... 1363s ../../../usr/lib/python3/dist-packages/pandas/tests/resample/test_timedelta.py .......................s 1363s 1363s =============================== warnings summary =============================== 1363s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1363s /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-uv47t70v' 1363s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1363s 1363s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1363s /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-1_iitkk0' 1363s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1363s 1363s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1363s -- generated xml file: /tmp/autopkgtest.gY8OYq/autopkgtest_tmp/test-data.xml --- 1363s ============================= slowest 30 durations ============================= 1363s 0.22s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-21600-s-0.25-D-2] 1363s 0.22s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-86400-s-1-D-1] 1363s 0.22s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-30-s-0.5-Min-1] 1363s 0.22s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-30-s-0.5-Min-2] 1363s 0.22s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-86400-s-1-D-2] 1363s 0.21s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-86400-s-1-D-3] 1363s 0.21s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-43200-s-0.5-D-2] 1363s 0.21s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-60-s-1-Min-1] 1363s 0.21s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-60-s-1-Min-2] 1363s 0.21s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-43200-s-0.5-D-1] 1363s 0.21s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-30-s-0.5-Min-3] 1363s 0.21s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-3600-s-1-h-2] 1363s 0.21s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-21600-s-0.25-D-3] 1363s 0.21s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-60-s-1-Min-3] 1363s 0.21s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-3600-s-1-h-1] 1363s 0.21s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-21600-s-0.25-D-1] 1363s 0.21s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-43200-s-0.5-D-3] 1363s 0.21s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-3600-s-1-h-3] 1363s 0.20s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-43200-s-0.5-D-3] 1363s 0.20s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-3600-s-1-h-1] 1363s 0.20s call tests/resample/test_datetime_index.py::test_resample_dtype_coercion[s] 1363s 0.20s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-30-s-0.5-Min-1] 1363s 0.20s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-30-s-0.5-Min-2] 1363s 0.19s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-60-s-1-Min-1] 1363s 0.19s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-86400-s-1-D-2] 1363s 0.19s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-30-s-0.5-Min-3] 1363s 0.19s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-60-s-1-Min-2] 1363s 0.19s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-86400-s-1-D-3] 1363s 0.19s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-3600-s-1-h-2] 1363s 0.19s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-21600-s-0.25-D-1] 1363s =========== 4117 passed, 8 skipped, 54 xfailed, 2 warnings in 37.46s =========== 1364s rdjoqkol test state = true 1364s + echo 'rdjoqkol test state = true' 1364s + for TEST_SUBSET in $modpath/tests/* 1364s + echo /usr/lib/python3/dist-packages/pandas/tests/reshape 1364s + grep -q -e __pycache__ 1364s + PANDAS_CI=1 1364s + LC_ALL=C.UTF-8 1364s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.gY8OYq/build.DBr/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/reshape 1365s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1365s 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" 1365s 1365s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1367s ============================= test session starts ============================== 1367s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1367s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1367s rootdir: /usr/lib/python3/dist-packages/pandas 1367s configfile: ../../../../../tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml 1367s plugins: typeguard-4.4.2, hypothesis-6.127.4, asyncio-0.25.1, forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, qt-4.4.0 1367s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1367s collected 2610 items / 1 deselected / 2609 selected 1367s 1367s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_append.py .................................................................................. 1368s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_append_common.py ...........................sssssssss....................................................... 1368s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_categorical.py ............. 1368s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_concat.py .............................................................................................. 1368s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_dataframe.py ..................... 1369s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_datetimes.py ..................................................................................................x......... 1369s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_empty.py .....................s.....s.....s.....s.....s.......... 1369s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_index.py ............................................................. 1369s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_invalid.py ....... 1369s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_series.py ............. 1369s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_sort.py .......... 1370s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/merge/test_join.py .......s..........................s....................................... 1374s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/merge/test_merge.py ..............................................................................................................................................................................................................................................................................................................................................................................................................................ssssssss..............................................................................................................................................................................................................................ss..........................................................................................................................................................................................................................................................................ssss........ 1375s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/merge/test_merge_asof.py .s...................................................................................................s.....................s....s.s.s.s.............sss.. 1375s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/merge/test_merge_cross.py ................. 1376s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/merge/test_merge_index_as_string.py ................................................................................ 1376s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/merge/test_merge_ordered.py ..................... 1377s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/merge/test_multi.py .....s.s.................................. 1378s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_crosstab.py ..................................... 1378s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_cut.py ..................................................................................................................................... 1379s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_from_dummies.py ......................................... 1380s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_get_dummies.py ...................................................................................................................................................ss 1380s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_melt.py ..........................................................s 1384s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_pivot.py ...........................................................................xx................................................................................................. 1384s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_pivot_multilevel.py .......... 1384s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_qcut.py ................................................................................ 1385s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_union_categoricals.py .......................................... 1385s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_util.py ................. 1385s 1385s =============================== warnings summary =============================== 1385s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1385s /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-6utyrn4f' 1385s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1385s 1385s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1385s /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-_0easyvv' 1385s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1385s 1385s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1385s -- generated xml file: /tmp/autopkgtest.gY8OYq/autopkgtest_tmp/test-data.xml --- 1385s ============================= slowest 30 durations ============================= 1385s 0.12s call tests/reshape/test_pivot.py::TestPivotTable::test_pivot_multi_functions 1385s 0.10s call tests/reshape/test_crosstab.py::TestCrosstab::test_crosstab_normalize 1385s 0.09s call tests/reshape/test_pivot.py::TestPivotTable::test_margins 1385s 0.08s call tests/reshape/merge/test_join.py::TestJoin::test_full_outer_join 1385s 0.08s call tests/reshape/merge/test_merge.py::TestMerge::test_merge_non_unique_indexes 1385s 0.07s call tests/reshape/test_crosstab.py::TestCrosstab::test_margin_normalize 1385s 0.07s call tests/reshape/concat/test_concat.py::TestConcatenate::test_concat_order 1385s 0.06s call tests/reshape/test_crosstab.py::TestCrosstab::test_margin_dropna6 1385s 0.06s call tests/reshape/merge/test_join.py::TestJoin::test_right_outer_join 1385s 0.06s call tests/reshape/test_pivot.py::TestPivotTable::test_pivot_timegrouper 1385s 0.05s call tests/reshape/test_qcut.py::test_qcut_binning_issues 1385s 0.05s call tests/reshape/test_crosstab.py::test_categoricals[category-category] 1385s 0.04s call tests/reshape/test_crosstab.py::TestCrosstab::test_crosstab_normalize_arrays 1385s 0.04s call tests/reshape/test_crosstab.py::test_categoricals[int64-category] 1385s 0.04s call tests/reshape/merge/test_multi.py::TestMergeMulti::test_compress_group_combinations 1385s 0.04s call tests/reshape/test_crosstab.py::test_categoricals[category-int64] 1385s 0.04s call tests/reshape/test_crosstab.py::test_categoricals[int64-int64] 1385s 0.04s call tests/reshape/test_pivot.py::TestPivotTable::test_daily 1385s 0.04s call tests/reshape/test_crosstab.py::TestCrosstab::test_crosstab_margins_set_margin_name 1385s 0.04s call tests/reshape/test_pivot.py::TestPivotTable::test_pivot_timegrouper_double 1385s 0.04s call tests/reshape/test_pivot.py::TestPivotTable::test_pivot_string_func_vs_func[f4-f_numpy4] 1385s 0.03s call tests/reshape/test_pivot.py::TestPivotTable::test_pivot_string_func_vs_func[f3-f_numpy3] 1385s 0.03s call tests/reshape/test_crosstab.py::TestCrosstab::test_crosstab_ndarray[tuple] 1385s 0.03s call tests/reshape/test_pivot.py::TestPivotTable::test_pivot_table_margins_name_with_aggfunc_list 1385s 0.03s call tests/reshape/test_crosstab.py::TestCrosstab::test_crosstab_ndarray[list] 1385s 0.03s call tests/reshape/test_crosstab.py::TestCrosstab::test_crosstab_ndarray[array] 1385s 0.03s call tests/reshape/merge/test_merge.py::TestMerge::test_validation 1385s 0.03s call tests/reshape/test_pivot.py::TestPivot::test_pivot_table_with_margins_and_numeric_column_names 1385s 0.03s call tests/reshape/test_crosstab.py::TestCrosstab::test_margin_dropna 1385s 0.03s call tests/reshape/test_crosstab.py::TestCrosstab::test_crosstab_duplicate_names 1385s ==== 2561 passed, 45 skipped, 1 deselected, 3 xfailed, 2 warnings in 19.69s ==== 1385s rdjoqkol test state = true 1385s + echo 'rdjoqkol test state = true' 1385s + for TEST_SUBSET in $modpath/tests/* 1385s + echo /usr/lib/python3/dist-packages/pandas/tests/scalar 1385s + grep -q -e __pycache__ 1385s + PANDAS_CI=1 1385s + LC_ALL=C.UTF-8 1385s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.gY8OYq/build.DBr/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/scalar 1386s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1386s 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" 1386s 1386s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1389s ============================= test session starts ============================== 1389s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1389s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1389s rootdir: /usr/lib/python3/dist-packages/pandas 1389s configfile: ../../../../../tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml 1389s plugins: typeguard-4.4.2, hypothesis-6.127.4, asyncio-0.25.1, forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, qt-4.4.0 1389s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1389s collected 4353 items 1389s 1389s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/interval/test_arithmetic.py ............................................ 1389s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/interval/test_constructors.py ......... 1390s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/interval/test_contains.py ................ 1390s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/interval/test_formats.py . 1390s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/interval/test_interval.py ............................................ 1390s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/interval/test_overlaps.py ................................................................................................................................................................. 1390s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/period/test_arithmetic.py .................................................................................... 1390s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/period/test_asfreq.py ....................... 1390s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/period/test_period.py ............................................................................................................................................................................................................................................................................................................... 1391s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/test_na_scalar.py .....................................................................................ss.....ss.....ss................................................................................................................................................................................ 1391s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/test_nat.py ........................................................................................................................s............s............................................................................................................................................................................................................................ 1391s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timedelta/methods/test_as_unit.py .... 1392s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timedelta/methods/test_round.py ................... 1392s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timedelta/test_arithmetic.py ................................................................................................................................ 1392s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timedelta/test_constructors.py ................................................................................................................................................................................................................................................................................................................... 1392s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timedelta/test_formats.py .............. 1395s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timedelta/test_timedelta.py .................................................................x............ 1395s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_as_unit.py .... 1395s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_normalize.py ................................................................................................................................................................. 1396s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_replace.py ............................................................................................................................ 1397s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_round.py ....................................................................................................................................................................................... 1397s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_timestamp_method.py . 1397s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_to_julian_date.py ..... 1397s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_to_pydatetime.py ....... 1397s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_tz_convert.py ............................................................................... 1397s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_tz_localize.py ................................................................................................................................................................................................. 1397s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/test_arithmetic.py ............................................................................................................. 1398s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/test_comparisons.py .............................. 1398s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/test_constructors.py ..................................................................xxx.............................................................. 1398s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/test_formats.py ........................................................................... 1402s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/test_timestamp.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ss..........................................................x....................................................................................................................................................................................................................................................................................................................................... 1402s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/test_timezones.py .................... 1402s 1402s =============================== warnings summary =============================== 1402s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1402s /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-8nns61cs' 1402s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1402s 1402s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1402s /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-1299_9b1' 1402s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1402s 1402s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1402s -- generated xml file: /tmp/autopkgtest.gY8OYq/autopkgtest_tmp/test-data.xml --- 1402s ============================= slowest 30 durations ============================= 1402s 2.60s call tests/scalar/timedelta/test_timedelta.py::TestTimedeltas::test_hash_equality_invariance 1402s 0.18s call tests/scalar/timestamp/methods/test_round.py::TestTimestampRound::test_round_sanity[floor] 1402s 0.18s call tests/scalar/timestamp/methods/test_round.py::TestTimestampRound::test_round_sanity[round] 1402s 0.16s call tests/scalar/timedelta/methods/test_round.py::TestTimedeltaRound::test_round_sanity[round] 1402s 0.15s call tests/scalar/timestamp/methods/test_round.py::TestTimestampRound::test_round_sanity[ceil] 1402s 0.15s call tests/scalar/timedelta/methods/test_round.py::TestTimedeltaRound::test_round_sanity[floor] 1402s 0.14s call tests/scalar/timedelta/methods/test_round.py::TestTimedeltaRound::test_round_sanity[ceil] 1402s 0.12s call tests/scalar/timestamp/test_timestamp.py::TestTimestampProperties::test_dow_parametric 1402s 0.04s teardown tests/scalar/timestamp/test_timezones.py::TestTimestampTZOperations::test_timestamp_timetz_equivalent_with_datetime_tz[zoneinfo.ZoneInfo(key='UTC')] 1402s 0.01s call tests/scalar/timestamp/test_timestamp.py::TestTimestampProperties::test_names[sv_FI.ISO8859-1-data1] 1402s 0.01s call tests/scalar/test_nat.py::test_nat_vector_field_access 1402s 0.01s setup tests/scalar/timestamp/test_arithmetic.py::TestTimestampArithmetic::test_subtracting_different_timezones[datetime.timezone(datetime.timedelta(seconds=3600))] 1402s 0.01s setup tests/scalar/timestamp/test_timestamp.py::TestTimestampProperties::test_names[eu_FR.UTF-8-data1] 1402s 0.01s call tests/scalar/test_nat.py::test_nat_arithmetic_td64_vector[Series-right_minus_left] 1402s 0.01s call tests/scalar/timestamp/test_timestamp.py::TestTimestampProperties::test_names[ga_IE.UTF-8-data1] 1402s 0.01s call tests/scalar/period/test_period.py::TestPeriodConstruction::test_period_cons_weekly[14-SUN] 1402s 0.01s call tests/scalar/timestamp/test_constructors.py::TestTimestampConstructorPositionalAndKeywordSupport::test_constructor_positional 1402s 0.01s setup tests/scalar/timestamp/test_timestamp.py::TestTimestampConversion::test_to_period_tz_warning 1402s 0.01s call tests/scalar/period/test_arithmetic.py::TestPeriodArithmetic::test_period_add_offset 1402s 0.01s call tests/scalar/period/test_period.py::TestPeriodMethods::test_to_timestamp 1402s 1402s (10 durations < 0.005s hidden. Use -vv to show these durations.) 1402s =========== 4338 passed, 10 skipped, 5 xfailed, 2 warnings in 15.87s =========== 1403s + echo 'rdjoqkol test state = true' 1403s + for TEST_SUBSET in $modpath/tests/* 1403s rdjoqkol test state = true 1403s + echo /usr/lib/python3/dist-packages/pandas/tests/series 1403s + grep -q -e __pycache__ 1403s + PANDAS_CI=1 1403s + LC_ALL=C.UTF-8 1403s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.gY8OYq/build.DBr/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/series 1404s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1404s 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" 1404s 1404s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1409s ============================= test session starts ============================== 1409s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1409s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1409s rootdir: /usr/lib/python3/dist-packages/pandas 1409s configfile: ../../../../../tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml 1409s plugins: typeguard-4.4.2, hypothesis-6.127.4, asyncio-0.25.1, forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, qt-4.4.0 1409s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1409s collected 13032 items / 2 skipped 1409s 1409s ../../../usr/lib/python3/dist-packages/pandas/tests/series/accessors/test_cat_accessor.py ................... 1418s ../../../usr/lib/python3/dist-packages/pandas/tests/series/accessors/test_dt_accessor.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 1418s ../../../usr/lib/python3/dist-packages/pandas/tests/series/accessors/test_sparse_accessor.py . 1418s ../../../usr/lib/python3/dist-packages/pandas/tests/series/accessors/test_str_accessor.py .. 1418s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_datetime.py ................. 1418s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_delitem.py .... 1418s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_get.py ............ 1419s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_getitem.py .............................................................................................. 1420s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_indexing.py .......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 1421s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_mask.py .... 1421s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_set_value.py ... 1426s ../../../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................................................................................................................................................................................................... 1426s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_take.py .... 1426s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_where.py ......................................................................................................................................................................................................... 1426s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_xs.py ...... 1426s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_add_prefix_suffix.py ... 1427s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_align.py ............................................................................................................... 1427s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_argsort.py ......... 1427s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_asof.py ....... 1427s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_astype.py ........................................................s....s..........................................................................x........sssssssss.................s 1427s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_autocorr.py . 1427s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_between.py ....... 1427s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_case_when.py ........... 1428s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_clip.py ....s.....s.....s.....s.....s.....s.....s.....s.....s.....s............ 1428s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_combine.py . 1428s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_combine_first.py .............................. 1428s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_compare.py ............ 1430s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_convert_dtypes.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................s......ss 1430s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_copy.py .......... 1430s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_count.py ... 1430s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_cov_corr.py ................ 1431s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_describe.py ...................................................... 1431s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_diff.py ....... 1431s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_drop.py ............................. 1432s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_drop_duplicates.py ..................................................................ssssss.............................................................................................................................................................................................................................................................................................................ss 1432s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_dropna.py ........... 1432s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_dtypes.py . 1432s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_duplicated.py .................. 1432s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_equals.py ..................................................... 1432s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_explode.py ...............ssss 1432s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_fillna.py ....................x.x.x................................................................................................................................. 1432s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_get_numeric_data.py . 1432s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_head_tail.py . 1432s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_infer_objects.py ....... 1432s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_info.py ........x..... 1434s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_interpolate.py x.........................................................................................................................................................................................................x.x............. 1434s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_is_monotonic.py .. 1434s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_is_unique.py ........ 1434s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_isin.py ......................................... 1434s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_isna.py .. 1434s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_item.py . 1434s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_map.py ......ss...................................xxx....................................................... 1434s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_matmul.py . 1434s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_nlargest.py ................................................................. 1434s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_nunique.py .. 1435s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_pct_change.py .............. 1435s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_pop.py . 1435s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_quantile.py ........................................ 1436s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_rank.py .......................................................................................................ssssssssssssssssssssssssssssss........................................................ssssssssssssssss.....ss.....ss.....ss.....ss.....ss.....................................................ssssssssssssssssss.............................................ssssssssssssssssss.............................................ssssssssssssssssss.............................................ssssssssssssssssss.............................................ssssssssssssssssss. 1436s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_reindex.py ................................... 1436s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_reindex_like.py .. 1436s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_rename.py ................ 1436s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_rename_axis.py ..... 1436s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_repeat.py ... 1437s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_replace.py ...........................s.......................................................................... 1437s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_reset_index.py ........s...... 1437s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_round.py ......................................................................................... 1437s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_searchsorted.py ........ 1437s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_set_name.py .. 1437s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_size.py ....... 1437s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_sort_index.py .............................................. 1437s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_sort_values.py .............. 1437s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_to_csv.py ................................... 1437s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_to_dict.py ...... 1437s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_to_frame.py ... 1437s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_to_numpy.py ...s. 1438s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_tolist.py ..........sss 1438s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_truncate.py .... 1438s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_tz_localize.py ................................................................ 1438s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_unique.py ....... 1438s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_unstack.py ....... 1438s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_update.py ....................s..... 1438s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_value_counts.py ................... 1438s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_values.py ... 1438s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_view.py .................................................. 1438s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_api.py ................................s.......................................................................................................................................................... 1447s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_arithmetic.py ..........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................x...............................x............. 1449s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_constructors.py ......................................................................................................................................................................................................................................x.........x............................................................................................s.................................xx.................................................sssssss.s...................... 1449s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_cumulative.py ....................................... 1449s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_formats.py .................................................. 1449s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_iteration.py ....... 1450s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_logical_ops.py ..........................xs 1450s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_missing.py ...x.. 1450s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_npfuncs.py ....s 1450s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_reductions.py ..............s............... 1450s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_subclass.py ......... 1451s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_ufunc.py .....................................................................xxxx........................................................................................................................................ 1451s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_unary.py .......................... 1451s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_validate.py ............................ 1451s 1451s =============================== warnings summary =============================== 1451s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1451s /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-i5vn36vk' 1451s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1451s 1451s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1451s /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-g_p1r4b0' 1451s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1451s 1451s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1451s -- generated xml file: /tmp/autopkgtest.gY8OYq/autopkgtest_tmp/test-data.xml --- 1451s ============================= slowest 30 durations ============================= 1451s 0.57s call tests/series/methods/test_rank.py::test_pct_max_many_rows 1451s 0.41s call tests/series/methods/test_cov_corr.py::TestSeriesCorr::test_corr[float64] 1451s 0.39s call tests/series/test_formats.py::TestSeriesRepr::test_latex_repr 1451s 0.25s call tests/series/test_arithmetic.py::TestNamePreservation::test_series_ops_name_retention[numexpr-names3-add-True-Series] 1451s 0.17s call tests/series/methods/test_convert_dtypes.py::TestSeriesConvertDtypes::test_convert_dtypes[test_cases12-params4] 1451s 0.13s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[br_FR.UTF-8] 1451s 0.07s call tests/series/methods/test_isin.py::TestSeriesIsIn::test_isin 1451s 0.07s teardown tests/series/test_validate.py::test_validate_bool_args[5.0-drop_duplicates] 1451s 0.03s call tests/series/indexing/test_datetime.py::test_getitem_str_month_with_datetimeindex 1451s 0.03s call tests/series/methods/test_to_csv.py::TestSeriesToCSV::test_to_csv_compression[xz-s3-cp737] 1451s 0.02s call tests/series/test_api.py::TestSeriesMisc::test_inspect_getmembers 1451s 0.02s call tests/series/methods/test_to_csv.py::TestSeriesToCSV::test_to_csv_compression[xz-s0-None] 1451s 0.02s call tests/series/accessors/test_cat_accessor.py::TestCatAccessor::test_dt_accessor_api_for_categorical[idx1] 1451s 0.02s call tests/series/methods/test_to_csv.py::TestSeriesToCSV::test_to_csv_compression[xz-s1-ascii] 1451s 0.02s call tests/series/methods/test_to_csv.py::TestSeriesToCSV::test_to_csv_compression[xz-s2-gb2312] 1451s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[ber_MA.UTF-8] 1451s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[aa_DJ.ISO8859-1] 1451s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[mnw_MM.UTF-8] 1451s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[mk_MK.ISO8859-5] 1451s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[ar_IQ.UTF-8] 1451s 0.02s call tests/series/accessors/test_cat_accessor.py::TestCatAccessor::test_dt_accessor_api_for_categorical[idx0] 1451s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[shn_MM.UTF-8] 1451s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[el_GR.ISO8859-7] 1451s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[aa_DJ.UTF-8] 1451s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[ckb_IQ.UTF-8] 1451s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[anp_IN.UTF-8] 1451s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[da_DK.UTF-8] 1451s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[gbm_IN.UTF-8] 1451s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[ar_KW.UTF-8] 1451s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[ar_SA.UTF-8] 1451s ========= 12405 passed, 606 skipped, 23 xfailed, 2 warnings in 47.69s ========== 1453s + echo 'rdjoqkol test state = true' 1453s + for TEST_SUBSET in $modpath/tests/* 1453s rdjoqkol test state = true 1453s + echo /usr/lib/python3/dist-packages/pandas/tests/strings 1453s + grep -q -e __pycache__ 1453s + PANDAS_CI=1 1453s + LC_ALL=C.UTF-8 1453s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.gY8OYq/build.DBr/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/strings 1454s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1454s 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" 1454s 1454s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1454s ============================= test session starts ============================== 1454s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1454s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1454s rootdir: /usr/lib/python3/dist-packages/pandas 1454s configfile: ../../../../../tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml 1454s plugins: typeguard-4.4.2, hypothesis-6.127.4, asyncio-0.25.1, forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, qt-4.4.0 1454s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1454s collected 3604 items 1454s 1459s ../../../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 1459s ../../../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 1460s ../../../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...................................... 1461s ../../../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 1461s ../../../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 1461s ../../../usr/lib/python3/dist-packages/pandas/tests/strings/test_get_dummies.py ..ss...ss. 1462s ../../../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 1462s ../../../usr/lib/python3/dist-packages/pandas/tests/strings/test_string_array.py ...............................................................................sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss....ssss....ssss.s 1463s ../../../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....... 1463s 1463s =============================== warnings summary =============================== 1463s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1463s /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-oedpc0wj' 1463s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1463s 1463s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1463s /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-kldn3qp1' 1463s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1463s 1463s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1463s -- generated xml file: /tmp/autopkgtest.gY8OYq/autopkgtest_tmp/test-data.xml --- 1463s ============================= slowest 30 durations ============================= 1463s 0.11s setup tests/strings/test_strings.py::test_count_mixed_object 1463s 0.02s call tests/strings/test_strings.py::test_empty_str_methods[string[python]] 1463s 0.02s teardown tests/strings/test_strings.py::test_series_str_decode 1463s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data7-names7] 1463s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data6-names6] 1463s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data5-names5] 1463s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data2-names2] 1463s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[object-data7-names7] 1463s 0.01s call tests/strings/test_strings.py::test_empty_str_methods[object] 1463s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data3-names3] 1463s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[object-data5-names5] 1463s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data1-names1] 1463s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[object-data0-names0] 1463s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data0-names0] 1463s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[object-data6-names6] 1463s 0.01s call tests/strings/test_extract.py::test_extract_expand_capture_groups[object] 1463s 0.01s call tests/strings/test_extract.py::test_extractall_same_as_extract_subject_index[string[python]] 1463s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data4-names4] 1463s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[object-data2-names2] 1463s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[object-data3-names3] 1463s 0.01s call tests/strings/test_extract.py::test_extract_expand_capture_groups[string[python]] 1463s 0.01s call tests/strings/test_extract.py::test_extractall[string[python]] 1463s 0.01s call tests/strings/test_extract.py::test_extractall_same_as_extract_subject_index[object] 1463s 0.01s call tests/strings/test_extract.py::test_extractall[object] 1463s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[object-data4-names4] 1463s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[object-data1-names1] 1463s 0.01s call tests/strings/test_cat.py::test_str_cat_mixed_inputs[index] 1463s 0.01s call tests/strings/test_extract.py::test_extractall_same_as_extract[object] 1463s 0.01s call tests/strings/test_extract.py::test_extractall_same_as_extract[string[python]] 1463s 0.01s call tests/strings/test_extract.py::test_extractall_stringindex[object] 1463s ========== 2704 passed, 887 skipped, 13 xfailed, 2 warnings in 8.88s =========== 1463s + echo 'rdjoqkol test state = true' 1463s + for TEST_SUBSET in $modpath/tests/* 1463s + echo /usr/lib/python3/dist-packages/pandas/tests/test_aggregation.py 1463s + grep -q -e __pycache__ 1463s rdjoqkol test state = true 1463s + PANDAS_CI=1 1463s + LC_ALL=C.UTF-8 1463s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.gY8OYq/build.DBr/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_aggregation.py 1464s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1464s 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" 1464s 1464s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1464s ============================= test session starts ============================== 1464s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1464s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1464s rootdir: /usr/lib/python3/dist-packages/pandas 1464s configfile: ../../../../../tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml 1464s plugins: typeguard-4.4.2, hypothesis-6.127.4, asyncio-0.25.1, forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, qt-4.4.0 1464s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1464s collected 8 items 1464s 1464s ../../../usr/lib/python3/dist-packages/pandas/tests/test_aggregation.py ........ 1464s 1464s =============================== warnings summary =============================== 1464s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1464s /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-e_im4pfe' 1464s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1464s 1464s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1464s /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-61k844d3' 1464s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1464s 1464s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1464s -- generated xml file: /tmp/autopkgtest.gY8OYq/autopkgtest_tmp/test-data.xml --- 1464s ============================= slowest 30 durations ============================= 1464s 1464s (24 durations < 0.005s hidden. Use -vv to show these durations.) 1464s ======================== 8 passed, 2 warnings in 0.12s ========================= 1464s rdjoqkol test state = true 1464s + echo 'rdjoqkol test state = true' 1464s + for TEST_SUBSET in $modpath/tests/* 1464s + echo /usr/lib/python3/dist-packages/pandas/tests/test_algos.py 1464s + grep -q -e __pycache__ 1464s + PANDAS_CI=1 1464s + LC_ALL=C.UTF-8 1464s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.gY8OYq/build.DBr/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_algos.py 1465s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1465s 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" 1465s 1465s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1466s ============================= test session starts ============================== 1466s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1466s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1466s rootdir: /usr/lib/python3/dist-packages/pandas 1466s configfile: ../../../../../tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml 1466s plugins: typeguard-4.4.2, hypothesis-6.127.4, asyncio-0.25.1, forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, qt-4.4.0 1466s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1466s collected 471 items 1466s 1469s ../../../usr/lib/python3/dist-packages/pandas/tests/test_algos.py ....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 1469s 1469s =============================== warnings summary =============================== 1469s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1469s /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-hhzyl9wp' 1469s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1469s 1469s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1469s /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-pfih4qrd' 1469s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1469s 1469s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1469s -- generated xml file: /tmp/autopkgtest.gY8OYq/autopkgtest_tmp/test-data.xml --- 1469s ============================= slowest 30 durations ============================= 1469s 2.09s call tests/test_algos.py::TestRank::test_pct_max_many_rows 1469s 0.49s call tests/test_algos.py::TestRank::test_scipy_compat[arr0] 1469s 0.03s call tests/test_algos.py::TestIsin::test_large 1469s 0.03s call tests/test_algos.py::TestIsin::test_same_nan_is_in_large_series 1469s 0.02s call tests/test_algos.py::TestDuplicated::test_datetime_likes 1469s 0.02s call tests/test_algos.py::TestIsin::test_same_nan_is_in_large 1469s 0.01s call tests/test_algos.py::TestUnique::test_object_refcount_bug 1469s 0.01s call tests/test_algos.py::TestValueCounts::test_value_counts_bins 1469s 1469s (22 durations < 0.005s hidden. Use -vv to show these durations.) 1469s ======================= 471 passed, 2 warnings in 3.92s ======================== 1470s rdjoqkol test state = true 1470s + echo 'rdjoqkol test state = true' 1470s + for TEST_SUBSET in $modpath/tests/* 1470s + echo /usr/lib/python3/dist-packages/pandas/tests/test_common.py 1470s + grep -q -e __pycache__ 1470s + PANDAS_CI=1 1470s + LC_ALL=C.UTF-8 1470s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.gY8OYq/build.DBr/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_common.py 1470s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1470s 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" 1470s 1470s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1471s ============================= test session starts ============================== 1471s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1471s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1471s rootdir: /usr/lib/python3/dist-packages/pandas 1471s configfile: ../../../../../tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml 1471s plugins: typeguard-4.4.2, hypothesis-6.127.4, asyncio-0.25.1, forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, qt-4.4.0 1471s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1471s collected 128 items 1471s 1472s ../../../usr/lib/python3/dist-packages/pandas/tests/test_common.py ...............x.x.............................................................................................................. 1472s 1472s =============================== warnings summary =============================== 1472s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1472s /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-ax1ev71d' 1472s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1472s 1472s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1472s /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-igjkmm89' 1472s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1472s 1472s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1472s -- generated xml file: /tmp/autopkgtest.gY8OYq/autopkgtest_tmp/test-data.xml --- 1472s ============================= slowest 30 durations ============================= 1472s 0.64s call tests/test_common.py::test_bz2_missing_import 1472s 0.51s call tests/test_common.py::test_str_size 1472s 1472s (28 durations < 0.005s hidden. Use -vv to show these durations.) 1472s ================== 126 passed, 2 xfailed, 2 warnings in 1.53s ================== 1472s + echo 'rdjoqkol test state = true' 1472s + for TEST_SUBSET in $modpath/tests/* 1472s + echo /usr/lib/python3/dist-packages/pandas/tests/test_downstream.py 1472s + grep -q -e __pycache__ 1472s rdjoqkol test state = true 1472s + PANDAS_CI=1 1472s + LC_ALL=C.UTF-8 1472s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.gY8OYq/build.DBr/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_downstream.py 1473s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1473s 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" 1473s 1473s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1474s ============================= test session starts ============================== 1474s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1474s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1474s rootdir: /usr/lib/python3/dist-packages/pandas 1474s configfile: ../../../../../tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml 1474s plugins: typeguard-4.4.2, hypothesis-6.127.4, asyncio-0.25.1, forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, qt-4.4.0 1474s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1474s collected 26 items 1474s 1478s ../../../usr/lib/python3/dist-packages/pandas/tests/test_downstream.py ....s..sssss.sx.........s. 1478s 1478s =============================== warnings summary =============================== 1478s tests/test_downstream.py::test_dask 1478s /usr/lib/python3/dist-packages/dask/dataframe/__init__.py:49: FutureWarning: 1478s Dask dataframe query planning is disabled because dask-expr is not installed. 1478s 1478s You can install it with `pip install dask[dataframe]` or `conda install dask`. 1478s This will raise in a future version. 1478s 1478s warnings.warn(msg, FutureWarning) 1478s 1478s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1478s /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-ybbwqo8f' 1478s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1478s 1478s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1478s /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-efn71cbs' 1478s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1478s 1478s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1478s -- generated xml file: /tmp/autopkgtest.gY8OYq/autopkgtest_tmp/test-data.xml --- 1478s ============================= slowest 30 durations ============================= 1478s 2.30s call tests/test_downstream.py::test_oo_optimizable 1478s 2.20s call tests/test_downstream.py::test_oo_optimized_datetime_index_unpickle 1478s 0.12s call tests/test_downstream.py::test_dask 1478s 0.02s call tests/test_downstream.py::test_construct_dask_float_array_int_dtype_match_ndarray 1478s 0.01s call tests/test_downstream.py::test_yaml_dump 1478s 0.01s call tests/test_downstream.py::test_frame_setitem_dask_array_into_new_col 1478s 0.01s call tests/test_downstream.py::test_dask_ufunc 1478s 1478s (23 durations < 0.005s hidden. Use -vv to show these durations.) 1478s ============= 17 passed, 8 skipped, 1 xfailed, 3 warnings in 5.30s ============= 1479s rdjoqkol test state = true 1479s + echo 'rdjoqkol test state = true' 1479s + for TEST_SUBSET in $modpath/tests/* 1479s + echo /usr/lib/python3/dist-packages/pandas/tests/test_errors.py 1479s + grep -q -e __pycache__ 1479s + PANDAS_CI=1 1479s + LC_ALL=C.UTF-8 1479s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.gY8OYq/build.DBr/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_errors.py 1480s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1480s 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" 1480s 1480s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1480s ============================= test session starts ============================== 1480s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1480s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1480s rootdir: /usr/lib/python3/dist-packages/pandas 1480s configfile: ../../../../../tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml 1480s plugins: typeguard-4.4.2, hypothesis-6.127.4, asyncio-0.25.1, forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, qt-4.4.0 1480s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1480s collected 36 items 1480s 1480s ../../../usr/lib/python3/dist-packages/pandas/tests/test_errors.py .................................... 1480s 1480s =============================== warnings summary =============================== 1480s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1480s /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-xr02a5gx' 1480s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1480s 1480s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1480s /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-t0qo7uuv' 1480s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1480s 1480s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1480s -- generated xml file: /tmp/autopkgtest.gY8OYq/autopkgtest_tmp/test-data.xml --- 1480s ============================= slowest 30 durations ============================= 1480s 1480s (30 durations < 0.005s hidden. Use -vv to show these durations.) 1480s ======================== 36 passed, 2 warnings in 0.14s ======================== 1480s + echo 'rdjoqkol test state = true' 1480s + for TEST_SUBSET in $modpath/tests/* 1480s + echo /usr/lib/python3/dist-packages/pandas/tests/test_expressions.py 1480s + grep -q -e __pycache__ 1480s rdjoqkol test state = true 1480s + PANDAS_CI=1 1480s + LC_ALL=C.UTF-8 1480s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.gY8OYq/build.DBr/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_expressions.py 1481s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1481s 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" 1481s 1481s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1481s ============================= test session starts ============================== 1481s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1481s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1481s rootdir: /usr/lib/python3/dist-packages/pandas 1481s configfile: ../../../../../tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml 1481s plugins: typeguard-4.4.2, hypothesis-6.127.4, asyncio-0.25.1, forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, qt-4.4.0 1481s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1481s collected 243 items 1481s 1483s ../../../usr/lib/python3/dist-packages/pandas/tests/test_expressions.py ................................................................................................................................................................................................................................................... 1483s 1483s =============================== warnings summary =============================== 1483s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1483s /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-31nl1q4x' 1483s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1483s 1483s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1483s /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-socnzitf' 1483s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1483s 1483s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1483s -- generated xml file: /tmp/autopkgtest.gY8OYq/autopkgtest_tmp/test-data.xml --- 1483s ============================= slowest 30 durations ============================= 1483s 0.04s call tests/test_expressions.py::TestExpressions::test_invalid 1483s 0.02s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[floordiv-False-_integer_integers] 1483s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[ne-True-_mixed] 1483s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[floordiv-False-_mixed] 1483s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[floordiv-True-_mixed] 1483s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[floordiv-True-_integer_integers] 1483s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[mod-False-_integer_integers] 1483s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[ne-False-_mixed] 1483s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[mod-False-_mixed] 1483s 0.01s call tests/test_expressions.py::TestExpressions::test_where[_mixed-True] 1483s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[mod-True-_mixed] 1483s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[truediv-True-_mixed] 1483s 0.01s call tests/test_expressions.py::TestExpressions::test_where[_mixed-False] 1483s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[floordiv-True-_frame] 1483s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[truediv-False-_mixed] 1483s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[floordiv-False-_frame] 1483s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[truediv-False-_integer] 1483s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[mod-True-_integer_integers] 1483s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[eq-True-_mixed] 1483s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[ge-False-_mixed] 1483s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[le-False-_mixed] 1483s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[gt-False-_mixed] 1483s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[lt-False-_mixed] 1483s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[gt-True-_mixed] 1483s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[eq-False-_mixed] 1483s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[truediv-True-_integer] 1483s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[lt-True-_mixed] 1483s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[le-True-_mixed] 1483s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[truediv-False-_integer_integers] 1483s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[mul-False-_mixed] 1483s ======================= 243 passed, 2 warnings in 1.86s ======================== 1483s + echo 'rdjoqkol test state = true' 1483s + for TEST_SUBSET in $modpath/tests/* 1483s + echo /usr/lib/python3/dist-packages/pandas/tests/test_flags.py 1483s rdjoqkol test state = true 1483s + grep -q -e __pycache__ 1483s + PANDAS_CI=1 1483s + LC_ALL=C.UTF-8 1483s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.gY8OYq/build.DBr/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_flags.py 1484s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1484s 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" 1484s 1484s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1484s ============================= test session starts ============================== 1484s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1484s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1484s rootdir: /usr/lib/python3/dist-packages/pandas 1484s configfile: ../../../../../tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml 1484s plugins: typeguard-4.4.2, hypothesis-6.127.4, asyncio-0.25.1, forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, qt-4.4.0 1484s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1484s collected 5 items 1484s 1484s ../../../usr/lib/python3/dist-packages/pandas/tests/test_flags.py ..... 1484s 1484s =============================== warnings summary =============================== 1484s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1484s /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-z1rxymva' 1484s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1484s 1484s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1484s /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-ouacsm9f' 1484s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1484s 1484s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1484s -- generated xml file: /tmp/autopkgtest.gY8OYq/autopkgtest_tmp/test-data.xml --- 1484s ============================= slowest 30 durations ============================= 1484s 1484s (15 durations < 0.005s hidden. Use -vv to show these durations.) 1484s ======================== 5 passed, 2 warnings in 0.12s ========================= 1484s rdjoqkol test state = true 1484s + echo 'rdjoqkol test state = true' 1484s + for TEST_SUBSET in $modpath/tests/* 1484s + echo /usr/lib/python3/dist-packages/pandas/tests/test_multilevel.py 1484s + grep -q -e __pycache__ 1484s + PANDAS_CI=1 1484s + LC_ALL=C.UTF-8 1484s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.gY8OYq/build.DBr/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_multilevel.py 1485s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1485s 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" 1485s 1485s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1485s ============================= test session starts ============================== 1485s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1485s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1485s rootdir: /usr/lib/python3/dist-packages/pandas 1485s configfile: ../../../../../tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml 1485s plugins: typeguard-4.4.2, hypothesis-6.127.4, asyncio-0.25.1, forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, qt-4.4.0 1485s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1485s collected 19 items 1485s 1485s ../../../usr/lib/python3/dist-packages/pandas/tests/test_multilevel.py ................... 1485s 1485s =============================== warnings summary =============================== 1485s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1485s /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-94jpyjhj' 1485s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1485s 1485s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1485s /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-mcqi7f9v' 1485s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1485s 1485s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1485s -- generated xml file: /tmp/autopkgtest.gY8OYq/autopkgtest_tmp/test-data.xml --- 1485s ============================= slowest 30 durations ============================= 1485s 0.01s call tests/test_multilevel.py::TestMultiLevel::test_reindex_level 1485s 0.01s call tests/test_multilevel.py::TestMultiLevel::test_alignment 1485s 0.01s call tests/test_multilevel.py::TestMultiLevel::test_reindex_level_partial_selection 1485s 0.01s setup tests/test_multilevel.py::TestMultiLevel::test_reindex_level 1485s 0.01s call tests/test_multilevel.py::TestMultiLevel::test_level_with_tuples 1485s 1485s (25 durations < 0.005s hidden. Use -vv to show these durations.) 1485s ======================== 19 passed, 2 warnings in 0.24s ======================== 1485s rdjoqkol test state = true 1485s + echo 'rdjoqkol test state = true' 1485s + for TEST_SUBSET in $modpath/tests/* 1485s + echo /usr/lib/python3/dist-packages/pandas/tests/test_nanops.py 1485s + grep -q -e __pycache__ 1485s + PANDAS_CI=1 1485s + LC_ALL=C.UTF-8 1485s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.gY8OYq/build.DBr/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_nanops.py 1486s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1486s 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" 1486s 1486s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1486s ============================= test session starts ============================== 1486s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1486s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1486s rootdir: /usr/lib/python3/dist-packages/pandas 1486s configfile: ../../../../../tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml 1486s plugins: typeguard-4.4.2, hypothesis-6.127.4, asyncio-0.25.1, forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, qt-4.4.0 1486s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1486s collected 245 items 1486s 1488s ../../../usr/lib/python3/dist-packages/pandas/tests/test_nanops.py ..............................................................................................................................................................................ss................................s.....s.....s.....s.....s.....s.....s 1488s 1488s =============================== warnings summary =============================== 1488s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1488s /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-m3womtcc' 1488s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1488s 1488s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1488s /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-bagw31sy' 1488s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1488s 1488s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1488s -- generated xml file: /tmp/autopkgtest.gY8OYq/autopkgtest_tmp/test-data.xml --- 1488s ============================= slowest 30 durations ============================= 1488s 0.41s call tests/test_nanops.py::TestnanopsDataFrame::test_nansem[True-0] 1488s 0.02s call tests/test_nanops.py::TestnanopsDataFrame::test_nankurt[True] 1488s 0.02s call tests/test_nanops.py::TestnanopsDataFrame::test_nanskew[True] 1488s 0.02s call tests/test_nanops.py::TestnanopsDataFrame::test_nansem[True-1] 1488s 0.02s call tests/test_nanops.py::TestnanopsDataFrame::test_nansem[True-2] 1488s 0.02s call tests/test_nanops.py::TestnanopsDataFrame::test_nancorr_spearman 1488s 0.02s call tests/test_nanops.py::TestnanopsDataFrame::test_nankurt[False] 1488s 0.02s call tests/test_nanops.py::TestnanopsDataFrame::test_nanskew[False] 1488s 0.02s call tests/test_nanops.py::TestnanopsDataFrame::test_nanmedian[True] 1488s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nansem[False-0] 1488s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nansem[False-2] 1488s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nansem[False-1] 1488s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nanmedian[False] 1488s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nanstd[True-2] 1488s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nanstd[True-0] 1488s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nanstd[True-1] 1488s 0.01s call tests/test_nanops.py::TestNanvarFixedValues::test_nanstd_nans 1488s 0.01s call tests/test_nanops.py::TestNanvarFixedValues::test_nanvar_nans 1488s 0.01s call tests/test_nanops.py::TestNanvarFixedValues::test_nanvar_axis 1488s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nanvar[True-0] 1488s 0.01s teardown tests/test_nanops.py::test_returned_dtype[min-None] 1488s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nanvar[True-1] 1488s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nanvar[True-2] 1488s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nansum[True] 1488s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nanops_with_warnings[True-reduction-min] 1488s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nanops_with_warnings[True-reduction-max] 1488s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nanmean[True] 1488s 1488s (3 durations < 0.005s hidden. Use -vv to show these durations.) 1488s ================== 236 passed, 9 skipped, 2 warnings in 1.38s ================== 1488s rdjoqkol test state = true 1488s + echo 'rdjoqkol test state = true' 1488s + for TEST_SUBSET in $modpath/tests/* 1488s + echo /usr/lib/python3/dist-packages/pandas/tests/test_optional_dependency.py 1488s + grep -q -e __pycache__ 1488s + PANDAS_CI=1 1488s + LC_ALL=C.UTF-8 1488s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.gY8OYq/build.DBr/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_optional_dependency.py 1489s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1489s 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" 1489s 1489s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1489s ============================= test session starts ============================== 1489s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1489s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1489s rootdir: /usr/lib/python3/dist-packages/pandas 1489s configfile: ../../../../../tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml 1489s plugins: typeguard-4.4.2, hypothesis-6.127.4, asyncio-0.25.1, forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, qt-4.4.0 1489s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1489s collected 5 items 1489s 1489s ../../../usr/lib/python3/dist-packages/pandas/tests/test_optional_dependency.py ..... 1489s 1489s =============================== warnings summary =============================== 1489s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1489s /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-r4o0jxp5' 1489s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1489s 1489s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1489s /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-a1yzw76k' 1489s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1489s 1489s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1489s -- generated xml file: /tmp/autopkgtest.gY8OYq/autopkgtest_tmp/test-data.xml --- 1489s ============================= slowest 30 durations ============================= 1489s 0.01s call tests/test_optional_dependency.py::test_xlrd_version_fallback 1489s 1489s (14 durations < 0.005s hidden. Use -vv to show these durations.) 1489s ======================== 5 passed, 2 warnings in 0.12s ========================= 1489s + echo 'rdjoqkol test state = true' 1489s + for TEST_SUBSET in $modpath/tests/* 1489s + echo /usr/lib/python3/dist-packages/pandas/tests/test_register_accessor.py 1489s + grep -q -e __pycache__ 1489s + PANDAS_CI=1 1489s + LC_ALL=C.UTF-8 1489s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.gY8OYq/build.DBr/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_register_accessor.py 1489s rdjoqkol test state = true 1490s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1490s 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" 1490s 1490s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1490s ============================= test session starts ============================== 1490s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1490s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1490s rootdir: /usr/lib/python3/dist-packages/pandas 1490s configfile: ../../../../../tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml 1490s plugins: typeguard-4.4.2, hypothesis-6.127.4, asyncio-0.25.1, forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, qt-4.4.0 1490s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1490s collected 7 items 1490s 1490s ../../../usr/lib/python3/dist-packages/pandas/tests/test_register_accessor.py ....... 1490s 1490s =============================== warnings summary =============================== 1490s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1490s /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-_b2740ro' 1490s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1490s 1490s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1490s /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-2620ds01' 1490s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1490s 1490s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1490s -- generated xml file: /tmp/autopkgtest.gY8OYq/autopkgtest_tmp/test-data.xml --- 1490s ============================= slowest 30 durations ============================= 1490s 1490s (21 durations < 0.005s hidden. Use -vv to show these durations.) 1490s ======================== 7 passed, 2 warnings in 0.12s ========================= 1490s + echo 'rdjoqkol test state = true' 1490s + for TEST_SUBSET in $modpath/tests/* 1490s rdjoqkol test state = true 1490s + echo /usr/lib/python3/dist-packages/pandas/tests/test_sorting.py 1490s + grep -q -e __pycache__ 1490s + PANDAS_CI=1 1490s + LC_ALL=C.UTF-8 1490s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.gY8OYq/build.DBr/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_sorting.py 1491s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1491s 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" 1491s 1491s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1491s ============================= test session starts ============================== 1491s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1491s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1491s rootdir: /usr/lib/python3/dist-packages/pandas 1491s configfile: ../../../../../tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml 1491s plugins: typeguard-4.4.2, hypothesis-6.127.4, asyncio-0.25.1, forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, qt-4.4.0 1491s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1491s collected 54 items / 15 deselected / 39 selected 1491s 1493s ../../../usr/lib/python3/dist-packages/pandas/tests/test_sorting.py ....................................... 1493s 1493s =============================== warnings summary =============================== 1493s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1493s /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-glwvy3gr' 1493s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1493s 1493s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1493s /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-fhcpx_cm' 1493s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1493s 1493s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1493s -- generated xml file: /tmp/autopkgtest.gY8OYq/autopkgtest_tmp/test-data.xml --- 1493s ============================= slowest 30 durations ============================= 1493s 0.81s call tests/test_sorting.py::TestSorting::test_int64_overflow_groupby_large_range 1493s 0.39s call tests/test_sorting.py::TestSorting::test_int64_overflow_groupby_large_df_shuffled[median] 1493s 0.39s call tests/test_sorting.py::TestSorting::test_int64_overflow_groupby_large_df_shuffled[mean] 1493s 0.01s call tests/test_sorting.py::TestMerge::test_int64_overflow_outer_merge 1493s 0.01s call tests/test_sorting.py::test_decons[codes_list1-shape1] 1493s 1493s (25 durations < 0.005s hidden. Use -vv to show these durations.) 1493s ================ 39 passed, 15 deselected, 2 warnings in 1.82s ================= 1493s rdjoqkol test state = true 1493s + echo 'rdjoqkol test state = true' 1493s + for TEST_SUBSET in $modpath/tests/* 1493s + echo /usr/lib/python3/dist-packages/pandas/tests/test_take.py 1493s + grep -q -e __pycache__ 1493s + PANDAS_CI=1 1493s + LC_ALL=C.UTF-8 1493s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.gY8OYq/build.DBr/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_take.py 1494s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1494s 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" 1494s 1494s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1494s ============================= test session starts ============================== 1494s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1494s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1494s rootdir: /usr/lib/python3/dist-packages/pandas 1494s configfile: ../../../../../tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml 1494s plugins: typeguard-4.4.2, hypothesis-6.127.4, asyncio-0.25.1, forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, qt-4.4.0 1494s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1494s collected 81 items 1494s 1494s ../../../usr/lib/python3/dist-packages/pandas/tests/test_take.py ................................................................................. 1494s 1494s =============================== warnings summary =============================== 1494s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1494s /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-lpd7luq0' 1494s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1494s 1494s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1494s /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-qxigkks8' 1494s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1494s 1494s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1494s -- generated xml file: /tmp/autopkgtest.gY8OYq/autopkgtest_tmp/test-data.xml --- 1494s ============================= slowest 30 durations ============================= 1494s 1494s (30 durations < 0.005s hidden. Use -vv to show these durations.) 1494s ======================== 81 passed, 2 warnings in 0.27s ======================== 1495s + echo 'rdjoqkol test state = true' 1495s + for TEST_SUBSET in $modpath/tests/* 1495s rdjoqkol test state = true 1495s + echo /usr/lib/python3/dist-packages/pandas/tests/tools 1495s + grep -q -e __pycache__ 1495s + PANDAS_CI=1 1495s + LC_ALL=C.UTF-8 1495s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.gY8OYq/build.DBr/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/tools 1495s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1495s 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" 1495s 1495s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1496s ============================= test session starts ============================== 1496s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1496s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1496s rootdir: /usr/lib/python3/dist-packages/pandas 1496s configfile: ../../../../../tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml 1496s plugins: typeguard-4.4.2, hypothesis-6.127.4, asyncio-0.25.1, forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, qt-4.4.0 1496s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1496s collected 1510 items 1496s 1500s ../../../usr/lib/python3/dist-packages/pandas/tests/tools/test_to_datetime.py ..................................................................................................................................................................................................................................ssssssss....................................................................ss................................................................................................................................................................................................................................................................................xx..........................................................................................................................................................................................................................................................................................................................................................................ssssssssss............................ 1501s ../../../usr/lib/python3/dist-packages/pandas/tests/tools/test_to_numeric.py ...s.s....................................................................................................................................................................................................................................................xx.......................................................................................................................ssssss.s.s.................................sss...sss.s....ssss.s.s 1501s ../../../usr/lib/python3/dist-packages/pandas/tests/tools/test_to_time.py ........... 1501s ../../../usr/lib/python3/dist-packages/pandas/tests/tools/test_to_timedelta.py .............................................X..........................ssssssssssss 1501s 1501s =============================== warnings summary =============================== 1501s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1501s /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-_2y78486' 1501s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1501s 1501s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1501s /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-2n7o37_m' 1501s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1501s 1501s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1501s -- generated xml file: /tmp/autopkgtest.gY8OYq/autopkgtest_tmp/test-data.xml --- 1501s ============================= slowest 30 durations ============================= 1501s 0.10s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[array-None-True] 1501s 0.10s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[array-%Y%m%d %H:%M:%S-None] 1501s 0.10s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[array-None-None] 1501s 0.10s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[array-%Y%m%d %H:%M:%S-True] 1501s 0.08s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[deque-None-None] 1501s 0.08s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[list-%Y%m%d %H:%M:%S-True] 1501s 0.08s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[deque-%Y%m%d %H:%M:%S-True] 1501s 0.08s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[deque-None-True] 1501s 0.08s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[tuple-None-True] 1501s 0.08s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[deque-%Y%m%d %H:%M:%S-None] 1501s 0.08s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[tuple-%Y%m%d %H:%M:%S-True] 1501s 0.08s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[list-None-True] 1501s 0.08s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[list-None-None] 1501s 0.08s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[tuple-None-None] 1501s 0.08s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[tuple-%Y%m%d %H:%M:%S-None] 1501s 0.08s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[list-%Y%m%d %H:%M:%S-None] 1501s 0.08s call tests/tools/test_to_datetime.py::TestTimeConversionFormats::test_to_datetime_parse_tzname_or_tzoffset[%Y-%m-%d %H:%M:%S %Z-dates0-expected_dates0] 1501s 0.04s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[Index-None-True] 1501s 0.04s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[Index-None-None] 1501s 0.04s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache_series[None-None] 1501s 0.04s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache_series[None-True] 1501s 0.04s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[Index-%Y%m%d %H:%M:%S-True] 1501s 0.04s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[Index-%Y%m%d %H:%M:%S-None] 1501s 0.04s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache_series[%Y%m%d %H:%M:%S-True] 1501s 0.04s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache_series[%Y%m%d %H:%M:%S-None] 1501s 0.03s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_fixed_offset 1501s 0.02s call tests/tools/test_to_datetime.py::TestToDatetimeMisc::test_to_datetime_timezone_name 1501s 0.01s teardown tests/tools/test_to_timedelta.py::test_from_timedelta_arrow_dtype[ms] 1501s 0.01s call tests/tools/test_to_datetime.py::TestToDatetimeDataFrame::test_dataframe[True] 1501s 0.01s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_array_of_dt64s[True-s] 1501s ====== 1450 passed, 55 skipped, 4 xfailed, 1 xpassed, 2 warnings in 5.62s ====== 1501s rdjoqkol test state = true 1501s + echo 'rdjoqkol test state = true' 1501s + for TEST_SUBSET in $modpath/tests/* 1501s + echo /usr/lib/python3/dist-packages/pandas/tests/tseries 1501s + grep -q -e __pycache__ 1501s + PANDAS_CI=1 1501s + LC_ALL=C.UTF-8 1501s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.gY8OYq/build.DBr/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/tseries 1502s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1502s 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" 1502s 1502s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1504s ============================= test session starts ============================== 1504s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1504s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1504s rootdir: /usr/lib/python3/dist-packages/pandas 1504s configfile: ../../../../../tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml 1504s plugins: typeguard-4.4.2, hypothesis-6.127.4, asyncio-0.25.1, forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, qt-4.4.0 1504s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1504s collected 5480 items 1504s 1504s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/frequencies/test_freq_code.py ................... 1504s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/frequencies/test_frequencies.py .......... 1506s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/frequencies/test_inference.py ......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 1506s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/holiday/test_calendar.py ........ 1506s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/holiday/test_federal.py ... 1507s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/holiday/test_holiday.py ................................................. 1507s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/holiday/test_observance.py ................................. 1507s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_business_day.py ....................... 1507s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_business_hour.py .............................................................................................. 1507s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_business_month.py ..................... 1507s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_business_quarter.py .............................................. 1507s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_business_year.py ................... 1508s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_common.py ...................................................................................................................................................................................................................................................................................XXXXXX..XXXXXXXXXXXX............................................................................................................................................................................................................................................................................................. 1508s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_custom_business_day.py ....... 1508s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_custom_business_hour.py ............................ 1509s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_custom_business_month.py .................................................... 1509s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_dst.py .......................... 1509s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_easter.py .......... 1509s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_fiscal.py ............................................................................................................................................. 1510s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_index.py ........................ 1510s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_month.py ............................................................ 1516s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_offsets.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................x..................................................................................................................................................................................................................................................x................................................................................................................................................................................................................................................ 1517s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_offsets_properties.py .. 1517s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_quarter.py ........................................................................................ 1519s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_ticks.py ............................................................................................................ 1519s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_week.py .............................................. 1520s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_year.py ................................. 1520s 1520s =============================== warnings summary =============================== 1520s tests/tseries/offsets/test_offsets_properties.py::test_on_offset_implementations 1520s /usr/lib/python3/dist-packages/dateutil/zoneinfo/__init__.py:26: UserWarning: I/O error(2): No such file or directory 1520s warnings.warn("I/O error({0}): {1}".format(e.errno, e.strerror)) 1520s 1520s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1520s /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-cksik1sc' 1520s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1520s 1520s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1520s /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-l8zxrhxl' 1520s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1520s 1520s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1520s -- generated xml file: /tmp/autopkgtest.gY8OYq/autopkgtest_tmp/test-data.xml --- 1520s ============================= slowest 30 durations ============================= 1520s 0.39s call tests/tseries/offsets/test_offsets_properties.py::test_on_offset_implementations 1520s 0.31s call tests/tseries/offsets/test_offsets_properties.py::test_shift_across_dst 1520s 0.25s call tests/tseries/offsets/test_ticks.py::test_tick_add_sub[Nano] 1520s 0.24s call tests/tseries/offsets/test_ticks.py::test_tick_equality[Minute] 1520s 0.24s call tests/tseries/offsets/test_ticks.py::test_tick_equality[Nano] 1520s 0.24s call tests/tseries/offsets/test_ticks.py::test_tick_equality[Hour] 1520s 0.23s call tests/tseries/offsets/test_ticks.py::test_tick_equality[Milli] 1520s 0.23s call tests/tseries/offsets/test_ticks.py::test_tick_equality[Micro] 1520s 0.23s call tests/tseries/offsets/test_ticks.py::test_tick_equality[Second] 1520s 0.14s call tests/tseries/offsets/test_custom_business_hour.py::TestCustomBusinessHour::test_us_federal_holiday_with_datetime 1520s 0.14s call tests/tseries/offsets/test_custom_business_day.py::TestCustomBusinessDay::test_calendar 1520s 0.10s call tests/tseries/offsets/test_ticks.py::test_tick_add_sub[Hour] 1520s 0.10s call tests/tseries/offsets/test_ticks.py::test_tick_add_sub[Second] 1520s 0.10s call tests/tseries/offsets/test_ticks.py::test_tick_add_sub[Minute] 1520s 0.10s call tests/tseries/offsets/test_ticks.py::test_tick_add_sub[Milli] 1520s 0.10s call tests/tseries/offsets/test_ticks.py::test_tick_add_sub[Micro] 1520s 0.09s call tests/tseries/offsets/test_common.py::test_apply_out_of_range[tzlocal()-Week] 1520s 0.07s call tests/tseries/offsets/test_index.py::test_apply_index[BYearEnd--2] 1520s 0.07s call tests/tseries/offsets/test_index.py::test_apply_index[BQuarterEnd--2] 1520s 0.07s call tests/tseries/offsets/test_business_month.py::test_apply_index[BusinessMonthBegin--2] 1520s 0.07s call tests/tseries/offsets/test_index.py::test_apply_index[BusinessMonthBegin--2] 1520s 0.07s call tests/tseries/offsets/test_index.py::test_apply_index[BQuarterBegin--2] 1520s 0.07s call tests/tseries/offsets/test_index.py::test_apply_index[BYearBegin--2] 1520s 0.07s call tests/tseries/offsets/test_index.py::test_apply_index[YearEnd--2] 1520s 0.07s call tests/tseries/offsets/test_index.py::test_apply_index[QuarterBegin--2] 1520s 0.07s call tests/tseries/offsets/test_index.py::test_apply_index[QuarterEnd--2] 1520s 0.07s call tests/tseries/offsets/test_index.py::test_apply_index[YearBegin--2] 1520s 0.06s call tests/tseries/offsets/test_index.py::test_apply_index[MonthBegin--2] 1520s 0.06s call tests/tseries/offsets/test_index.py::test_apply_index[BusinessMonthEnd-1] 1520s 0.06s call tests/tseries/offsets/test_business_month.py::test_apply_index[BusinessMonthEnd-1] 1520s =========== 5460 passed, 2 xfailed, 18 xpassed, 3 warnings in 17.26s =========== 1520s + echo 'rdjoqkol test state = true' 1520s + for TEST_SUBSET in $modpath/tests/* 1520s + echo /usr/lib/python3/dist-packages/pandas/tests/tslibs 1520s + grep -q -e __pycache__ 1520s rdjoqkol test state = true 1520s + PANDAS_CI=1 1520s + LC_ALL=C.UTF-8 1520s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.gY8OYq/build.DBr/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/tslibs 1521s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1521s 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" 1521s 1521s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1522s ============================= test session starts ============================== 1522s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1522s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1522s rootdir: /usr/lib/python3/dist-packages/pandas 1522s configfile: ../../../../../tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml 1522s plugins: typeguard-4.4.2, hypothesis-6.127.4, asyncio-0.25.1, forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, qt-4.4.0 1522s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1522s collected 1140 items 1522s 1522s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_api.py . 1522s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_array_to_datetime.py ............................................ 1522s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_ccalendar.py ................. 1525s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_conversion.py ...................................................................... 1525s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_fields.py .... 1525s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_libfrequencies.py ............ 1525s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_liboffsets.py .......................................................................... 1525s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_np_datetime.py ........ 1525s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_npy_units.py .. 1525s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_parse_iso8601.py ................................................... 1533s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_parsing.py .............................................................................................................................................x...x................................. 1533s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_period.py ....................................... 1533s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_resolution.py ................... 1533s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_strptime.py ....... 1533s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_timedeltas.py ......................... 1534s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_timezones.py ........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 1534s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_to_offset.py ................................................................................................... 1534s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_tzconversion.py . 1534s 1534s =============================== warnings summary =============================== 1534s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1534s /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-0lx0wla6' 1534s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1534s 1534s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1534s /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-p0dyiwvw' 1534s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1534s 1534s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1534s -- generated xml file: /tmp/autopkgtest.gY8OYq/autopkgtest_tmp/test-data.xml --- 1534s ============================= slowest 30 durations ============================= 1534s 0.41s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%m %Y-True-.] 1534s 0.36s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly['dateutil/Asia/Singapore'] 1534s 0.33s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%m %Y-False-.] 1534s 0.27s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly[tzlocal()] 1534s 0.24s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly[datetime.timezone(datetime.timedelta(days=-1, seconds=82800), 'foo')] 1534s 0.23s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly['UTC-02:15'] 1534s 0.23s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly['-02:15'] 1534s 0.23s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly[datetime.timezone(datetime.timedelta(seconds=3600))] 1534s 0.23s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly['+01:15'] 1534s 0.23s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly['UTC+01:15'] 1534s 0.22s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly[pytz.FixedOffset(-300)] 1534s 0.21s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly[pytz.FixedOffset(300)] 1534s 0.20s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%y %m %d-True-/] 1534s 0.16s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly['Asia/Tokyo'] 1534s 0.16s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%m %d %Y-False- ] 1534s 0.12s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y%m%d-False-/] 1534s 0.12s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y%m%d-False- ] 1534s 0.12s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y%m%d-True-.] 1534s 0.12s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y%m%d-False--] 1534s 0.12s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y%m%d-False-.] 1534s 0.12s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y%m%d-True--] 1534s 0.12s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%y%m%d-True- ] 1534s 0.12s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%y%m%d-True--] 1534s 0.12s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y %m %d-False--] 1534s 0.12s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y%m%d-True-/] 1534s 0.12s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%y %m %d-True- ] 1534s 0.12s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%y%m%d-False--] 1534s 0.12s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%y %m %d-False-.] 1534s 0.12s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y %m %d-True- ] 1534s 0.12s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y %m %d-False- ] 1534s ================= 1138 passed, 2 xfailed, 2 warnings in 12.67s ================= 1534s rdjoqkol test state = true 1534s + echo 'rdjoqkol test state = true' 1534s + for TEST_SUBSET in $modpath/tests/* 1534s + echo /usr/lib/python3/dist-packages/pandas/tests/util 1534s + grep -q -e __pycache__ 1534s + PANDAS_CI=1 1534s + LC_ALL=C.UTF-8 1534s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.gY8OYq/build.DBr/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/util 1535s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1535s 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" 1535s 1535s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1536s ============================= test session starts ============================== 1536s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1536s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1536s rootdir: /usr/lib/python3/dist-packages/pandas 1536s configfile: ../../../../../tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml 1536s plugins: typeguard-4.4.2, hypothesis-6.127.4, asyncio-0.25.1, forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, qt-4.4.0 1536s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1536s collected 916 items 1536s 1536s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_almost_equal.py .................................................................................................................................................................... 1536s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_attr_equal.py .......................................... 1536s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_categorical_equal.py .......... 1536s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_extension_array_equal.py ..................... 1536s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_frame_equal.py ............................................................................................................... 1536s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_index_equal.py ................................................................ 1536s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_interval_array_equal.py ....... 1536s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_numpy_array_equal.py ......................... 1536s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_produces_warning.py ............................................................................................................................ 1537s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_series_equal.py .............................................................................................. 1537s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_deprecate.py ... 1537s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_deprecate_kwarg.py .............. 1537s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_deprecate_nonkeyword_arguments.py ................... 1537s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_doc.py .... 1537s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_hashing.py ..................................................................................................................................................... 1537s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_numba.py . 1537s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_rewrite_warning.py .......... 1537s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_shares_memory.py .s 1538s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_show_versions.py .... 1538s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_util.py ...sx.. 1538s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_validate_args.py ...... 1538s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_validate_args_and_kwargs.py ...... 1538s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_validate_inclusive.py ........... 1538s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_validate_kwargs.py .................. 1538s 1538s =============================== warnings summary =============================== 1538s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1538s /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-qr4hssk6' 1538s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1538s 1538s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1538s /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-l_uiqoxn' 1538s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1538s 1538s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1538s -- generated xml file: /tmp/autopkgtest.gY8OYq/autopkgtest_tmp/test-data.xml --- 1538s ============================= slowest 30 durations ============================= 1538s 0.71s call tests/util/test_show_versions.py::test_show_versions 1538s 0.02s call tests/util/test_hashing.py::test_same_len_hash_collisions[0-7] 1538s 0.02s call tests/util/test_hashing.py::test_same_len_hash_collisions[1-7] 1538s 0.01s call tests/util/test_show_versions.py::test_show_versions_console_json 1538s 0.01s call tests/util/test_hashing.py::test_same_len_hash_collisions[0-6] 1538s 0.01s call tests/util/test_hashing.py::test_same_len_hash_collisions[1-6] 1538s 0.01s call tests/util/test_show_versions.py::test_json_output_match 1538s 0.01s teardown tests/util/test_validate_kwargs.py::test_validate_bool_kwarg[None-copy] 1538s 0.01s call tests/util/test_hashing.py::test_same_len_hash_collisions[0-5] 1538s 0.01s call tests/util/test_hashing.py::test_same_len_hash_collisions[1-5] 1538s 0.01s call tests/util/test_assert_produces_warning.py::TestFalseOrNoneExpectedWarning::test_no_raise_without_warning[False] 1538s 1538s (19 durations < 0.005s hidden. Use -vv to show these durations.) 1538s ============ 913 passed, 2 skipped, 1 xfailed, 2 warnings in 2.86s ============= 1538s rdjoqkol test state = true 1538s + echo 'rdjoqkol test state = true' 1538s + for TEST_SUBSET in $modpath/tests/* 1538s + echo /usr/lib/python3/dist-packages/pandas/tests/window 1538s + grep -q -e __pycache__ 1538s + PANDAS_CI=1 1538s + LC_ALL=C.UTF-8 1538s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.gY8OYq/build.DBr/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/window 1539s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1539s 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" 1539s 1539s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1541s ============================= test session starts ============================== 1541s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1541s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1541s rootdir: /usr/lib/python3/dist-packages/pandas 1541s configfile: ../../../../../tmp/autopkgtest.gY8OYq/build.DBr/src/pyproject.toml 1541s plugins: typeguard-4.4.2, hypothesis-6.127.4, asyncio-0.25.1, forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, qt-4.4.0 1541s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1541s collected 10242 items / 536 deselected / 1 skipped / 9706 selected 1541s 1544s ../../../usr/lib/python3/dist-packages/pandas/tests/window/moments/test_moments_consistency_ewm.py ................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 1545s ../../../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................................................................................................................................................................................................................................................................................ 1548s ../../../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................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 1550s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_api.py ......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 1551s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_apply.py ...s....sssss..........s..s....................................................... 1552s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_base_indexer.py .................................................................................................................................................................................................................................... 1552s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_cython_aggregations.py ........................................................................ 1558s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_dtypes.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 1558s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_ewm.py .......................................................................................................................................................................................................................................ssssssssssss........ssssssssssssssss................ 1560s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_expanding.py ..........x................................................................................................................................................................................................ss....s...................s..s......s............................................................................................. 1561s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_groupby.py ................................................................................................................... 1561s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_numba.py ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss 1564s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_pairwise.py ......................................................................................................................................................X.....X.....X.....X.....X.....X.....X.....X.....X................................................................................................................. 1567s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling.py .........................................................................................................................................................................................................................................................................................................................................................................................XXXX........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 1569s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling_functions.py .................................................................................................................................................................................................................................................................................................................................................................................................................................. 1570s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling_quantile.py .......................................................................................................................................................................................... 1570s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling_skew_kurt.py .................................................................... 1571s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_timeseries_window.py ..................................................................................s 1571s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_win_type.py ............................................................................................................................................................................................................................................................................................... 1571s 1571s =============================== warnings summary =============================== 1571s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1571s /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-grlq5pq6' 1571s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1571s 1571s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1571s /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-uwomy3d0' 1571s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1571s 1571s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1571s -- generated xml file: /tmp/autopkgtest.gY8OYq/autopkgtest_tmp/test-data.xml --- 1571s ============================= slowest 30 durations ============================= 1571s 0.43s call tests/window/test_rolling_functions.py::test_rolling_functions_window_non_shrinkage[14] 1571s 0.16s call tests/window/test_apply.py::test_time_rule_frame[False] 1571s 0.15s teardown tests/window/test_numba.py::TestEngine::test_dont_cache_args[False-True-True-table-expanding-window_kwargs1] 1571s 0.10s call tests/window/test_apply.py::test_frame[False] 1571s 0.06s teardown tests/window/test_win_type.py::test_rolling_center_axis_1 1571s 0.06s call tests/window/test_expanding.py::test_expanding_cov_pairwise 1571s 0.06s call tests/window/test_expanding.py::test_expanding_corr_pairwise 1571s 0.05s call tests/window/test_apply.py::test_center_reindex_frame[False] 1571s 0.04s call tests/window/test_apply.py::test_min_periods[False-1-0] 1571s 0.04s call tests/window/test_apply.py::test_min_periods[False-None-0] 1571s 0.04s call tests/window/test_apply.py::test_center_reindex_series[False] 1571s 0.03s call tests/window/test_pairwise.py::test_rolling_pairwise_cov_corr[corr] 1571s 0.03s call tests/window/test_pairwise.py::test_rolling_pairwise_cov_corr[cov] 1571s 0.03s call tests/window/test_ewm.py::test_ewm_pairwise_cov_corr[corr] 1571s 0.03s call tests/window/test_pairwise.py::test_flex_binary_frame[corr] 1571s 0.03s call tests/window/test_expanding.py::test_expanding_cov_pairwise_diff_length 1571s 0.03s call tests/window/test_apply.py::test_nans[False] 1571s 0.02s call tests/window/test_ewm.py::test_ewm_pairwise_cov_corr[cov] 1571s 0.02s call tests/window/test_pairwise.py::test_flex_binary_frame[cov] 1571s 0.02s call tests/window/test_expanding.py::test_expanding_corr_pairwise_diff_length 1571s 0.02s call tests/window/test_pairwise.py::TestPairwise::test_cov_mulittindex 1571s 0.02s call tests/window/test_apply.py::test_min_periods[False-2-0] 1571s 0.02s call tests/window/test_api.py::test_agg[None] 1571s 0.02s call tests/window/test_api.py::test_agg[5] 1571s 0.02s call tests/window/test_api.py::test_agg[2] 1571s 0.02s call tests/window/test_api.py::test_agg[1] 1571s 0.02s call tests/window/test_api.py::test_agg[10] 1571s 0.02s call tests/window/test_pairwise.py::TestPairwise::test_pairwise_with_other[pairwise_frames0-5] 1571s 0.02s call tests/window/test_rolling_functions.py::test_rolling_median_memory_error 1571s 0.02s call tests/window/test_groupby.py::TestExpanding::test_expanding_corr_cov[corr] 1571s = 9001 passed, 650 skipped, 536 deselected, 43 xfailed, 13 xpassed, 2 warnings in 32.12s = 1572s rdjoqkol test state = true 1572s + echo 'rdjoqkol test state = true' 1572s + true 1573s autopkgtest [17:49:52]: test unittests3: -----------------------] 1577s unittests3 PASS 1577s autopkgtest [17:49:56]: test unittests3: - - - - - - - - - - results - - - - - - - - - - 1580s autopkgtest [17:49:59]: test ignoredtests: preparing testbed 1582s Reading package lists... 1582s Building dependency tree... 1582s Reading state information... 1582s Starting pkgProblemResolver with broken count: 0 1583s Starting 2 pkgProblemResolver with broken count: 0 1583s Done 1583s The following NEW packages will be installed: 1583s libpq5 python3-psycopg2 python3-pymysql 1584s 0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded. 1584s Need to get 290 kB of archives. 1584s After this operation, 895 kB of additional disk space will be used. 1584s Get:1 http://ftpmaster.internal/ubuntu questing/main armhf libpq5 armhf 17.4-1 [125 kB] 1584s Get:2 http://ftpmaster.internal/ubuntu questing/main armhf python3-psycopg2 armhf 2.9.10-1build1 [125 kB] 1584s Get:3 http://ftpmaster.internal/ubuntu questing/main armhf python3-pymysql all 1.1.1-2ubuntu1 [39.5 kB] 1584s Fetched 290 kB in 1s (564 kB/s) 1584s Selecting previously unselected package libpq5:armhf. 1584s (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 ... 87921 files and directories currently installed.) 1584s Preparing to unpack .../libpq5_17.4-1_armhf.deb ... 1584s Unpacking libpq5:armhf (17.4-1) ... 1584s Selecting previously unselected package python3-psycopg2. 1584s Preparing to unpack .../python3-psycopg2_2.9.10-1build1_armhf.deb ... 1584s Unpacking python3-psycopg2 (2.9.10-1build1) ... 1584s Selecting previously unselected package python3-pymysql. 1585s Preparing to unpack .../python3-pymysql_1.1.1-2ubuntu1_all.deb ... 1585s Unpacking python3-pymysql (1.1.1-2ubuntu1) ... 1585s Setting up libpq5:armhf (17.4-1) ... 1585s Setting up python3-psycopg2 (2.9.10-1build1) ... 1585s Setting up python3-pymysql (1.1.1-2ubuntu1) ... 1585s Processing triggers for libc-bin (2.41-6ubuntu1) ... 1592s autopkgtest [17:50:11]: test ignoredtests: [----------------------- 1594s === python3.13 === 1595s 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 1595s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1595s 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" 1595s 1595s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1597s ============================= test session starts ============================== 1597s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1597s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1597s rootdir: /usr/lib/python3/dist-packages/pandas/tests 1597s plugins: typeguard-4.4.2, hypothesis-6.127.4, asyncio-0.25.1, forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, qt-4.4.0 1597s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1597s collected 10446 items / 536 deselected / 2 skipped / 9910 selected 1597s 1600s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_ufunc.py ....xx.........xxxxxxxx.xx....s. 1601s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_timegrouper.py ..............................s 1603s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/transform/test_numba.py sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss 1604s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/aggregate/test_numba.py sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss 1604s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_numba.py . 1632s ../../../usr/lib/python3/dist-packages/pandas/tests/window/moments/test_moments_consistency_ewm.py ................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 1643s ../../../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................................................................................................................................................................................................................................................................................ 1663s ../../../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................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 1684s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_api.py ......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 1687s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_apply.py ...s....sssss..........s..s....................................................... 1694s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_base_indexer.py .................................................................................................................................................................................................................................... 1696s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_cython_aggregations.py ........................................................................ 1756s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_dtypes.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 1765s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_ewm.py .......................................................................................................................................................................................................................................ssssssssssss........ssssssssssssssss................ 1775s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_expanding.py ..........x................................................................................................................................................................................................ss....s...................s..s......s............................................................................................. 1780s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_groupby.py ................................................................................................................... 1792s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_numba.py ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss 1805s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_pairwise.py ......................................................................................................................................................X.....X.....X.....X.....X.....X.....X.....X.....X................................................................................................................. 1830s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling.py .........................................................................................................................................................................................................................................................................................................................................................................................XXXX........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 1842s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling_functions.py .................................................................................................................................................................................................................................................................................................................................................................................................................................. 1847s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling_quantile.py .......................................................................................................................................................................................... 1855s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling_skew_kurt.py .................................................................... 1857s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_timeseries_window.py ..................................................................................s 1980s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_win_type.py ............................................................................................................................................................................................................................................................................................... 1980s 1980s =============================== warnings summary =============================== 1980s ../../../usr/lib/python3/dist-packages/pandas/compat/_optional.py:130 1980s ../../../usr/lib/python3/dist-packages/pandas/compat/_optional.py:130 1980s ../../../usr/lib/python3/dist-packages/pandas/compat/_optional.py:130 1980s ../../../usr/lib/python3/dist-packages/pandas/compat/_optional.py:130 1980s ../../../usr/lib/python3/dist-packages/pandas/compat/_optional.py:130 1980s /usr/lib/python3/dist-packages/pandas/compat/_optional.py:130: UserWarning: Non-x86 system detected, Numba may give wrong results or crash 1980s warnings.warn(warn_numba_platform) 1980s 1980s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_numba.py:11 1980s /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 1980s pytestmark = pytest.mark.single_cpu 1980s 1980s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_timegrouper.py:944 1980s /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 1980s @pytest.mark.single_cpu 1980s 1980s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/transform/test_numba.py:14 1980s /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 1980s pytestmark = pytest.mark.single_cpu 1980s 1980s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/aggregate/test_numba.py:22 1980s /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 1980s pytestmark = pytest.mark.single_cpu 1980s 1980s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/aggregate/test_numba.py:230 1980s /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 1980s @pytest.mark.single_cpu 1980s 1980s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_numba.py:21 1980s /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 1980s pytestmark = pytest.mark.single_cpu 1980s 1980s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_numba.py:326 1980s /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 1980s @pytest.mark.slow 1980s 1980s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_online.py:11 1980s /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 1980s pytestmark = pytest.mark.single_cpu 1980s 1980s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling_skew_kurt.py:155 1980s /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 1980s @pytest.mark.slow 1980s 1980s frame/test_ufunc.py: 32 warnings 1980s groupby/test_timegrouper.py: 31 warnings 1980s groupby/transform/test_numba.py: 53 warnings 1980s groupby/aggregate/test_numba.py: 35 warnings 1980s util/test_numba.py: 1 warning 1980s window/moments/test_moments_consistency_ewm.py: 1088 warnings 1980s window/moments/test_moments_consistency_expanding.py: 380 warnings 1980s window/moments/test_moments_consistency_rolling.py: 760 warnings 1980s window/test_api.py: 937 warnings 1980s window/test_apply.py: 82 warnings 1980s window/test_base_indexer.py: 228 warnings 1980s window/test_cython_aggregations.py: 72 warnings 1980s window/test_dtypes.py: 2580 warnings 1980s window/test_ewm.py: 283 warnings 1980s window/test_expanding.py: 333 warnings 1980s window/test_groupby.py: 115 warnings 1980s window/test_numba.py: 51 warnings 1980s window/test_pairwise.py: 312 warnings 1980s window/test_rolling.py: 888 warnings 1980s window/test_rolling_functions.py: 418 warnings 1980s window/test_rolling_quantile.py: 186 warnings 1980s window/test_rolling_skew_kurt.py: 68 warnings 1980s window/test_timeseries_window.py: 83 warnings 1980s window/test_win_type.py: 287 warnings 1980s /usr/lib/python3/dist-packages/py/_process/forkedfunc.py:45: DeprecationWarning: This process (pid=6583) is multi-threaded, use of fork() may lead to deadlocks in the child. 1980s pid = os.fork() 1980s 1980s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1980s /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-bfke0h_a' 1980s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1980s 1980s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1980s /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-07bc_1fi' 1980s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1980s 1980s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1980s = 9051 passed, 793 skipped, 536 deselected, 55 xfailed, 13 xpassed, 9319 warnings in 384.15s (0:06:24) = 1980s various xfailed tests - see xfail_tests_nonintel_io.patch, ignore_test_1094417_1088988.patch 1981s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1981s 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" 1981s 1981s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1982s ============================= test session starts ============================== 1982s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1982s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1982s rootdir: /usr/lib/python3/dist-packages/pandas/tests 1982s plugins: typeguard-4.4.2, hypothesis-6.127.4, asyncio-0.25.1, forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, qt-4.4.0 1982s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1982s collected 366 items 1982s 1997s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py ...................................................FFFFFFFFF................................................................................................................................... 2000s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_append.py ....F................ 2006s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_store.py ............................................F..................... 2011s ../../../usr/lib/python3/dist-packages/pandas/tests/test_downstream.py ....s..sssss.sF.........s. 2015s ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py ..F.............FF..F.sFFFFFF................................. 2015s 2015s =================================== FAILURES =================================== 2015s ___________________________ test_complibs[blosc2-1] ____________________________ 2015s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-52/test_complibs_blosc2_1_0') 2015s lvl = 1, lib = 'blosc2' 2015s request = > 2015s 2015s @pytest.mark.parametrize("lvl", range(10)) 2015s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 2015s @pytest.mark.filterwarnings("ignore:object name is not a valid") 2015s @pytest.mark.skipif( 2015s not PY311 and is_ci_environment() and is_platform_linux(), 2015s reason="Segfaulting in a CI environment" 2015s # with xfail, would sometimes raise UnicodeDecodeError 2015s # invalid state byte 2015s ) 2015s def test_complibs(tmp_path, lvl, lib, request): 2015s # GH14478 2015s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 2015s request.applymarker( 2015s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 2015s ) 2015s df = DataFrame( 2015s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 2015s ) 2015s 2015s # Remove lzo if its not available on this platform 2015s if not tables.which_lib_version("lzo"): 2015s pytest.skip("lzo not available") 2015s # Remove bzip2 if its not available on this platform 2015s if not tables.which_lib_version("bzip2"): 2015s pytest.skip("bzip2 not available") 2015s 2015s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 2015s gname = f"{lvl}_{lib}" 2015s 2015s # Write and read file to see if data is consistent 2015s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 2015s result = read_hdf(tmpfile, gname) 2015s tm.assert_frame_equal(result, df) 2015s 2015s # Open file and check metadata for correct amount of compression 2015s with tables.open_file(tmpfile, mode="r") as h5table: 2015s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 2015s assert node.filters.complevel == lvl 2015s if lvl == 0: 2015s assert node.filters.complib is None 2015s else: 2015s > assert node.filters.complib == lib 2015s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 2015s E 2015s E - blosc2 2015s E + blosc2:blosclz 2015s 2015s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 2015s ___________________________ test_complibs[blosc2-2] ____________________________ 2015s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-53/test_complibs_blosc2_2_0') 2015s lvl = 2, lib = 'blosc2' 2015s request = > 2015s 2015s @pytest.mark.parametrize("lvl", range(10)) 2015s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 2015s @pytest.mark.filterwarnings("ignore:object name is not a valid") 2015s @pytest.mark.skipif( 2015s not PY311 and is_ci_environment() and is_platform_linux(), 2015s reason="Segfaulting in a CI environment" 2015s # with xfail, would sometimes raise UnicodeDecodeError 2015s # invalid state byte 2015s ) 2015s def test_complibs(tmp_path, lvl, lib, request): 2015s # GH14478 2015s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 2015s request.applymarker( 2015s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 2015s ) 2015s df = DataFrame( 2015s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 2015s ) 2015s 2015s # Remove lzo if its not available on this platform 2015s if not tables.which_lib_version("lzo"): 2015s pytest.skip("lzo not available") 2015s # Remove bzip2 if its not available on this platform 2015s if not tables.which_lib_version("bzip2"): 2015s pytest.skip("bzip2 not available") 2015s 2015s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 2015s gname = f"{lvl}_{lib}" 2015s 2015s # Write and read file to see if data is consistent 2015s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 2015s result = read_hdf(tmpfile, gname) 2015s tm.assert_frame_equal(result, df) 2015s 2015s # Open file and check metadata for correct amount of compression 2015s with tables.open_file(tmpfile, mode="r") as h5table: 2015s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 2015s assert node.filters.complevel == lvl 2015s if lvl == 0: 2015s assert node.filters.complib is None 2015s else: 2015s > assert node.filters.complib == lib 2015s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 2015s E 2015s E - blosc2 2015s E + blosc2:blosclz 2015s 2015s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 2015s ___________________________ test_complibs[blosc2-3] ____________________________ 2015s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-54/test_complibs_blosc2_3_0') 2015s lvl = 3, lib = 'blosc2' 2015s request = > 2015s 2015s @pytest.mark.parametrize("lvl", range(10)) 2015s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 2015s @pytest.mark.filterwarnings("ignore:object name is not a valid") 2015s @pytest.mark.skipif( 2015s not PY311 and is_ci_environment() and is_platform_linux(), 2015s reason="Segfaulting in a CI environment" 2015s # with xfail, would sometimes raise UnicodeDecodeError 2015s # invalid state byte 2015s ) 2015s def test_complibs(tmp_path, lvl, lib, request): 2015s # GH14478 2015s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 2015s request.applymarker( 2015s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 2015s ) 2015s df = DataFrame( 2015s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 2015s ) 2015s 2015s # Remove lzo if its not available on this platform 2015s if not tables.which_lib_version("lzo"): 2015s pytest.skip("lzo not available") 2015s # Remove bzip2 if its not available on this platform 2015s if not tables.which_lib_version("bzip2"): 2015s pytest.skip("bzip2 not available") 2015s 2015s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 2015s gname = f"{lvl}_{lib}" 2015s 2015s # Write and read file to see if data is consistent 2015s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 2015s result = read_hdf(tmpfile, gname) 2015s tm.assert_frame_equal(result, df) 2015s 2015s # Open file and check metadata for correct amount of compression 2015s with tables.open_file(tmpfile, mode="r") as h5table: 2015s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 2015s assert node.filters.complevel == lvl 2015s if lvl == 0: 2015s assert node.filters.complib is None 2015s else: 2015s > assert node.filters.complib == lib 2015s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 2015s E 2015s E - blosc2 2015s E + blosc2:blosclz 2015s 2015s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 2015s ___________________________ test_complibs[blosc2-4] ____________________________ 2015s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-55/test_complibs_blosc2_4_0') 2015s lvl = 4, lib = 'blosc2' 2015s request = > 2015s 2015s @pytest.mark.parametrize("lvl", range(10)) 2015s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 2015s @pytest.mark.filterwarnings("ignore:object name is not a valid") 2015s @pytest.mark.skipif( 2015s not PY311 and is_ci_environment() and is_platform_linux(), 2015s reason="Segfaulting in a CI environment" 2015s # with xfail, would sometimes raise UnicodeDecodeError 2015s # invalid state byte 2015s ) 2015s def test_complibs(tmp_path, lvl, lib, request): 2015s # GH14478 2015s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 2015s request.applymarker( 2015s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 2015s ) 2015s df = DataFrame( 2015s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 2015s ) 2015s 2015s # Remove lzo if its not available on this platform 2015s if not tables.which_lib_version("lzo"): 2015s pytest.skip("lzo not available") 2015s # Remove bzip2 if its not available on this platform 2015s if not tables.which_lib_version("bzip2"): 2015s pytest.skip("bzip2 not available") 2015s 2015s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 2015s gname = f"{lvl}_{lib}" 2015s 2015s # Write and read file to see if data is consistent 2015s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 2015s result = read_hdf(tmpfile, gname) 2015s tm.assert_frame_equal(result, df) 2015s 2015s # Open file and check metadata for correct amount of compression 2015s with tables.open_file(tmpfile, mode="r") as h5table: 2015s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 2015s assert node.filters.complevel == lvl 2015s if lvl == 0: 2015s assert node.filters.complib is None 2015s else: 2015s > assert node.filters.complib == lib 2015s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 2015s E 2015s E - blosc2 2015s E + blosc2:blosclz 2015s 2015s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 2015s ___________________________ test_complibs[blosc2-5] ____________________________ 2015s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-56/test_complibs_blosc2_5_0') 2015s lvl = 5, lib = 'blosc2' 2015s request = > 2015s 2015s @pytest.mark.parametrize("lvl", range(10)) 2015s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 2015s @pytest.mark.filterwarnings("ignore:object name is not a valid") 2015s @pytest.mark.skipif( 2015s not PY311 and is_ci_environment() and is_platform_linux(), 2015s reason="Segfaulting in a CI environment" 2015s # with xfail, would sometimes raise UnicodeDecodeError 2015s # invalid state byte 2015s ) 2015s def test_complibs(tmp_path, lvl, lib, request): 2015s # GH14478 2015s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 2015s request.applymarker( 2015s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 2015s ) 2015s df = DataFrame( 2015s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 2015s ) 2015s 2015s # Remove lzo if its not available on this platform 2015s if not tables.which_lib_version("lzo"): 2015s pytest.skip("lzo not available") 2015s # Remove bzip2 if its not available on this platform 2015s if not tables.which_lib_version("bzip2"): 2015s pytest.skip("bzip2 not available") 2015s 2015s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 2015s gname = f"{lvl}_{lib}" 2015s 2015s # Write and read file to see if data is consistent 2015s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 2015s result = read_hdf(tmpfile, gname) 2015s tm.assert_frame_equal(result, df) 2015s 2015s # Open file and check metadata for correct amount of compression 2015s with tables.open_file(tmpfile, mode="r") as h5table: 2015s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 2015s assert node.filters.complevel == lvl 2015s if lvl == 0: 2015s assert node.filters.complib is None 2015s else: 2015s > assert node.filters.complib == lib 2015s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 2015s E 2015s E - blosc2 2015s E + blosc2:blosclz 2015s 2015s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 2015s ___________________________ test_complibs[blosc2-6] ____________________________ 2015s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-57/test_complibs_blosc2_6_0') 2015s lvl = 6, lib = 'blosc2' 2015s request = > 2015s 2015s @pytest.mark.parametrize("lvl", range(10)) 2015s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 2015s @pytest.mark.filterwarnings("ignore:object name is not a valid") 2015s @pytest.mark.skipif( 2015s not PY311 and is_ci_environment() and is_platform_linux(), 2015s reason="Segfaulting in a CI environment" 2015s # with xfail, would sometimes raise UnicodeDecodeError 2015s # invalid state byte 2015s ) 2015s def test_complibs(tmp_path, lvl, lib, request): 2015s # GH14478 2015s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 2015s request.applymarker( 2015s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 2015s ) 2015s df = DataFrame( 2015s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 2015s ) 2015s 2015s # Remove lzo if its not available on this platform 2015s if not tables.which_lib_version("lzo"): 2015s pytest.skip("lzo not available") 2015s # Remove bzip2 if its not available on this platform 2015s if not tables.which_lib_version("bzip2"): 2015s pytest.skip("bzip2 not available") 2015s 2015s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 2015s gname = f"{lvl}_{lib}" 2015s 2015s # Write and read file to see if data is consistent 2015s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 2015s result = read_hdf(tmpfile, gname) 2015s tm.assert_frame_equal(result, df) 2015s 2015s # Open file and check metadata for correct amount of compression 2015s with tables.open_file(tmpfile, mode="r") as h5table: 2015s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 2015s assert node.filters.complevel == lvl 2015s if lvl == 0: 2015s assert node.filters.complib is None 2015s else: 2015s > assert node.filters.complib == lib 2015s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 2015s E 2015s E - blosc2 2015s E + blosc2:blosclz 2015s 2015s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 2015s ___________________________ test_complibs[blosc2-7] ____________________________ 2015s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-58/test_complibs_blosc2_7_0') 2015s lvl = 7, lib = 'blosc2' 2015s request = > 2015s 2015s @pytest.mark.parametrize("lvl", range(10)) 2015s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 2015s @pytest.mark.filterwarnings("ignore:object name is not a valid") 2015s @pytest.mark.skipif( 2015s not PY311 and is_ci_environment() and is_platform_linux(), 2015s reason="Segfaulting in a CI environment" 2015s # with xfail, would sometimes raise UnicodeDecodeError 2015s # invalid state byte 2015s ) 2015s def test_complibs(tmp_path, lvl, lib, request): 2015s # GH14478 2015s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 2015s request.applymarker( 2015s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 2015s ) 2015s df = DataFrame( 2015s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 2015s ) 2015s 2015s # Remove lzo if its not available on this platform 2015s if not tables.which_lib_version("lzo"): 2015s pytest.skip("lzo not available") 2015s # Remove bzip2 if its not available on this platform 2015s if not tables.which_lib_version("bzip2"): 2015s pytest.skip("bzip2 not available") 2015s 2015s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 2015s gname = f"{lvl}_{lib}" 2015s 2015s # Write and read file to see if data is consistent 2015s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 2015s result = read_hdf(tmpfile, gname) 2015s tm.assert_frame_equal(result, df) 2015s 2015s # Open file and check metadata for correct amount of compression 2015s with tables.open_file(tmpfile, mode="r") as h5table: 2015s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 2015s assert node.filters.complevel == lvl 2015s if lvl == 0: 2015s assert node.filters.complib is None 2015s else: 2015s > assert node.filters.complib == lib 2015s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 2015s E 2015s E - blosc2 2015s E + blosc2:blosclz 2015s 2015s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 2015s ___________________________ test_complibs[blosc2-8] ____________________________ 2015s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-59/test_complibs_blosc2_8_0') 2015s lvl = 8, lib = 'blosc2' 2015s request = > 2015s 2015s @pytest.mark.parametrize("lvl", range(10)) 2015s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 2015s @pytest.mark.filterwarnings("ignore:object name is not a valid") 2015s @pytest.mark.skipif( 2015s not PY311 and is_ci_environment() and is_platform_linux(), 2015s reason="Segfaulting in a CI environment" 2015s # with xfail, would sometimes raise UnicodeDecodeError 2015s # invalid state byte 2015s ) 2015s def test_complibs(tmp_path, lvl, lib, request): 2015s # GH14478 2015s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 2015s request.applymarker( 2015s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 2015s ) 2015s df = DataFrame( 2015s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 2015s ) 2015s 2015s # Remove lzo if its not available on this platform 2015s if not tables.which_lib_version("lzo"): 2015s pytest.skip("lzo not available") 2015s # Remove bzip2 if its not available on this platform 2015s if not tables.which_lib_version("bzip2"): 2015s pytest.skip("bzip2 not available") 2015s 2015s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 2015s gname = f"{lvl}_{lib}" 2015s 2015s # Write and read file to see if data is consistent 2015s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 2015s result = read_hdf(tmpfile, gname) 2015s tm.assert_frame_equal(result, df) 2015s 2015s # Open file and check metadata for correct amount of compression 2015s with tables.open_file(tmpfile, mode="r") as h5table: 2015s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 2015s assert node.filters.complevel == lvl 2015s if lvl == 0: 2015s assert node.filters.complib is None 2015s else: 2015s > assert node.filters.complib == lib 2015s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 2015s E 2015s E - blosc2 2015s E + blosc2:blosclz 2015s 2015s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 2015s ___________________________ test_complibs[blosc2-9] ____________________________ 2015s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-60/test_complibs_blosc2_9_0') 2015s lvl = 9, lib = 'blosc2' 2015s request = > 2015s 2015s @pytest.mark.parametrize("lvl", range(10)) 2015s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 2015s @pytest.mark.filterwarnings("ignore:object name is not a valid") 2015s @pytest.mark.skipif( 2015s not PY311 and is_ci_environment() and is_platform_linux(), 2015s reason="Segfaulting in a CI environment" 2015s # with xfail, would sometimes raise UnicodeDecodeError 2015s # invalid state byte 2015s ) 2015s def test_complibs(tmp_path, lvl, lib, request): 2015s # GH14478 2015s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 2015s request.applymarker( 2015s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 2015s ) 2015s df = DataFrame( 2015s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 2015s ) 2015s 2015s # Remove lzo if its not available on this platform 2015s if not tables.which_lib_version("lzo"): 2015s pytest.skip("lzo not available") 2015s # Remove bzip2 if its not available on this platform 2015s if not tables.which_lib_version("bzip2"): 2015s pytest.skip("bzip2 not available") 2015s 2015s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 2015s gname = f"{lvl}_{lib}" 2015s 2015s # Write and read file to see if data is consistent 2015s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 2015s result = read_hdf(tmpfile, gname) 2015s tm.assert_frame_equal(result, df) 2015s 2015s # Open file and check metadata for correct amount of compression 2015s with tables.open_file(tmpfile, mode="r") as h5table: 2015s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 2015s assert node.filters.complevel == lvl 2015s if lvl == 0: 2015s assert node.filters.complib is None 2015s else: 2015s > assert node.filters.complib == lib 2015s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 2015s E 2015s E - blosc2 2015s E + blosc2:blosclz 2015s 2015s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 2015s ______________________ test_append_frame_column_oriented _______________________ 2015s self = 2015s node = , kwargs = {'side': 'right'} 2015s value = 2015s slobj = slice(0, 4, None) 2015s 2015s def visit_Subscript(self, node, **kwargs) -> ops.Term: 2015s # only allow simple subscripts 2015s 2015s value = self.visit(node.value) 2015s slobj = self.visit(node.slice) 2015s try: 2015s value = value.value 2015s except AttributeError: 2015s pass 2015s 2015s if isinstance(slobj, Term): 2015s # In py39 np.ndarray lookups with Term containing int raise 2015s slobj = slobj.value 2015s 2015s try: 2015s > return self.const_type(value[slobj], self.env) 2015s E TypeError: 'builtin_function_or_method' object is not subscriptable 2015s 2015s /usr/lib/python3/dist-packages/pandas/core/computation/pytables.py:468: TypeError 2015s 2015s The above exception was the direct cause of the following exception: 2015s 2015s setup_path = 'tmp.__6220db3e-2f2e-4ed3-be71-8eaf7e054160__.h5' 2015s 2015s @pytest.mark.xfail(condition=PY312 or is_crashing_arch, reason="https://bugs.debian.org/1055801 and https://bugs.debian.org/790925",raises=ValueError,strict=False, run=not is_crashing_arch) 2015s def test_append_frame_column_oriented(setup_path): 2015s with ensure_clean_store(setup_path) as store: 2015s # column oriented 2015s df = DataFrame( 2015s np.random.default_rng(2).standard_normal((10, 4)), 2015s columns=Index(list("ABCD"), dtype=object), 2015s index=date_range("2000-01-01", periods=10, freq="B"), 2015s ) 2015s df.index = df.index._with_freq(None) # freq doesn't round-trip 2015s 2015s _maybe_remove(store, "df1") 2015s store.append("df1", df.iloc[:, :2], axes=["columns"]) 2015s store.append("df1", df.iloc[:, 2:]) 2015s tm.assert_frame_equal(store["df1"], df) 2015s 2015s result = store.select("df1", "columns=A") 2015s expected = df.reindex(columns=["A"]) 2015s tm.assert_frame_equal(expected, result) 2015s 2015s # selection on the non-indexable 2015s > result = store.select("df1", ("columns=A", "index=df.index[0:4]")) 2015s 2015s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_append.py:311: 2015s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2015s /usr/lib/python3/dist-packages/pandas/io/pytables.py:915: in select 2015s return it.get_result() 2015s /usr/lib/python3/dist-packages/pandas/io/pytables.py:2038: in get_result 2015s results = self.func(self.start, self.stop, where) 2015s /usr/lib/python3/dist-packages/pandas/io/pytables.py:899: in func 2015s return s.read(start=_start, stop=_stop, where=_where, columns=columns) 2015s /usr/lib/python3/dist-packages/pandas/io/pytables.py:4640: in read 2015s result = self._read_axes(where=where, start=start, stop=stop) 2015s /usr/lib/python3/dist-packages/pandas/io/pytables.py:3826: in _read_axes 2015s selection = Selection(self, where=where, start=start, stop=stop) 2015s /usr/lib/python3/dist-packages/pandas/io/pytables.py:5367: in __init__ 2015s self.terms = self.generate(where) 2015s /usr/lib/python3/dist-packages/pandas/io/pytables.py:5380: in generate 2015s return PyTablesExpr(where, queryables=q, encoding=self.table.encoding) 2015s /usr/lib/python3/dist-packages/pandas/core/computation/pytables.py:610: in __init__ 2015s self.terms = self.parse() 2015s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:824: in parse 2015s return self._visitor.visit(self.expr) 2015s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 2015s return visitor(node, **kwargs) 2015s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:417: in visit_Module 2015s return self.visit(expr, **kwargs) 2015s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 2015s return visitor(node, **kwargs) 2015s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:420: in visit_Expr 2015s return self.visit(node.value, **kwargs) 2015s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 2015s return visitor(node, **kwargs) 2015s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:742: in visit_BoolOp 2015s return reduce(visitor, operands) 2015s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:736: in visitor 2015s rhs = self._try_visit_binop(y) 2015s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:731: in _try_visit_binop 2015s return self.visit(bop) 2015s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 2015s return visitor(node, **kwargs) 2015s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:715: in visit_Compare 2015s return self.visit(binop) 2015s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 2015s return visitor(node, **kwargs) 2015s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:531: in visit_BinOp 2015s op, op_class, left, right = self._maybe_transform_eq_ne(node) 2015s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:453: in _maybe_transform_eq_ne 2015s right = self.visit(node.right, side="right") 2015s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 2015s return visitor(node, **kwargs) 2015s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2015s 2015s self = 2015s node = , kwargs = {'side': 'right'} 2015s value = 2015s slobj = slice(0, 4, None) 2015s 2015s def visit_Subscript(self, node, **kwargs) -> ops.Term: 2015s # only allow simple subscripts 2015s 2015s value = self.visit(node.value) 2015s slobj = self.visit(node.slice) 2015s try: 2015s value = value.value 2015s except AttributeError: 2015s pass 2015s 2015s if isinstance(slobj, Term): 2015s # In py39 np.ndarray lookups with Term containing int raise 2015s slobj = slobj.value 2015s 2015s try: 2015s return self.const_type(value[slobj], self.env) 2015s except TypeError as err: 2015s > raise ValueError( 2015s f"cannot subscript {repr(value)} with {repr(slobj)}" 2015s ) from err 2015s E ValueError: cannot subscript with slice(0, 4, None) 2015s 2015s /usr/lib/python3/dist-packages/pandas/core/computation/pytables.py:470: ValueError 2015s __________________________ test_select_filter_corner ___________________________ 2015s setup_path = 'tmp.__a200dddc-f983-43ef-a4b9-4ec65577f6f3__.h5' 2015s 2015s @pytest.mark.xfail(condition=PY312 or is_crashing_arch, reason="https://bugs.debian.org/1055801 and https://bugs.debian.org/790925",raises=ValueError,strict=False, run=not is_crashing_arch) 2015s def test_select_filter_corner(setup_path): 2015s df = DataFrame(np.random.default_rng(2).standard_normal((50, 100))) 2015s df.index = [f"{c:3d}" for c in df.index] 2015s df.columns = [f"{c:3d}" for c in df.columns] 2015s 2015s with ensure_clean_store(setup_path) as store: 2015s store.put("frame", df, format="table") 2015s 2015s crit = "columns=df.columns[:75]" 2015s > result = store.select("frame", [crit]) 2015s 2015s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_store.py:899: 2015s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2015s /usr/lib/python3/dist-packages/pandas/io/pytables.py:915: in select 2015s return it.get_result() 2015s /usr/lib/python3/dist-packages/pandas/io/pytables.py:2038: in get_result 2015s results = self.func(self.start, self.stop, where) 2015s /usr/lib/python3/dist-packages/pandas/io/pytables.py:899: in func 2015s return s.read(start=_start, stop=_stop, where=_where, columns=columns) 2015s /usr/lib/python3/dist-packages/pandas/io/pytables.py:4640: in read 2015s result = self._read_axes(where=where, start=start, stop=stop) 2015s /usr/lib/python3/dist-packages/pandas/io/pytables.py:3826: in _read_axes 2015s selection = Selection(self, where=where, start=start, stop=stop) 2015s /usr/lib/python3/dist-packages/pandas/io/pytables.py:5367: in __init__ 2015s self.terms = self.generate(where) 2015s /usr/lib/python3/dist-packages/pandas/io/pytables.py:5380: in generate 2015s return PyTablesExpr(where, queryables=q, encoding=self.table.encoding) 2015s /usr/lib/python3/dist-packages/pandas/core/computation/pytables.py:610: in __init__ 2015s self.terms = self.parse() 2015s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:824: in parse 2015s return self._visitor.visit(self.expr) 2015s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 2015s return visitor(node, **kwargs) 2015s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:417: in visit_Module 2015s return self.visit(expr, **kwargs) 2015s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 2015s return visitor(node, **kwargs) 2015s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:420: in visit_Expr 2015s return self.visit(node.value, **kwargs) 2015s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 2015s return visitor(node, **kwargs) 2015s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:715: in visit_Compare 2015s return self.visit(binop) 2015s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 2015s return visitor(node, **kwargs) 2015s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:531: in visit_BinOp 2015s op, op_class, left, right = self._maybe_transform_eq_ne(node) 2015s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:453: in _maybe_transform_eq_ne 2015s right = self.visit(node.right, side="right") 2015s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 2015s return visitor(node, **kwargs) 2015s /usr/lib/python3/dist-packages/pandas/core/computation/pytables.py:456: in visit_Subscript 2015s value = self.visit(node.value) 2015s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 2015s return visitor(node, **kwargs) 2015s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2015s 2015s self = 2015s node = , kwargs = {}, attr = 'columns' 2015s value = , ctx = 2015s resolved = 'df' 2015s 2015s def visit_Attribute(self, node, **kwargs): 2015s attr = node.attr 2015s value = node.value 2015s 2015s ctx = type(node.ctx) 2015s if ctx == ast.Load: 2015s # resolve the value 2015s resolved = self.visit(value) 2015s 2015s # try to get the value to see if we are another expression 2015s try: 2015s resolved = resolved.value 2015s except AttributeError: 2015s pass 2015s 2015s try: 2015s return self.term_type(getattr(resolved, attr), self.env) 2015s except AttributeError: 2015s # something like datetime.datetime where scope is overridden 2015s if isinstance(value, ast.Name) and value.id == attr: 2015s return resolved 2015s 2015s > raise ValueError(f"Invalid Attribute context {ctx.__name__}") 2015s E ValueError: Invalid Attribute context Load 2015s 2015s /usr/lib/python3/dist-packages/pandas/core/computation/pytables.py:496: ValueError 2015s __________________ test_frame_setitem_dask_array_into_new_col __________________ 2015s @pytest.mark.xfail( 2015s condition=True,#not IS64, 2015s reason="ignoring https://bugs.debian.org/1094417 to unblock transition",#"dask has different nativesize-int vs int64 type rules", 2015s strict=False, 2015s ) 2015s def test_frame_setitem_dask_array_into_new_col(): 2015s # GH#47128 2015s 2015s # dask sets "compute.use_numexpr" to False, so catch the current value 2015s # and ensure to reset it afterwards to avoid impacting other tests 2015s olduse = pd.get_option("compute.use_numexpr") 2015s 2015s try: 2015s da = td.versioned_importorskip("dask.array") 2015s 2015s dda = da.array([1, 2]) 2015s df = DataFrame({"a": ["a", "b"]}) 2015s df["b"] = dda 2015s df["c"] = dda 2015s df.loc[[False, True], "b"] = 100 2015s result = df.loc[[1], :] 2015s expected = DataFrame({"a": ["b"], "b": [100], "c": [2]}, index=[1]) 2015s > tm.assert_frame_equal(result, expected) 2015s E AssertionError: Attributes of DataFrame.iloc[:, 1] (column name="b") are different 2015s E 2015s E Attribute "dtype" are different 2015s E [left]: int32 2015s E [right]: int64 2015s 2015s /usr/lib/python3/dist-packages/pandas/tests/test_downstream.py:256: AssertionError 2015s ________ TestDataFrameToXArray.test_to_xarray_index_types[datetime-tz] _________ 2015s self = 2015s index_flat = DatetimeIndex(['2020-01-01 00:00:00-08:00', '2020-01-02 00:00:00-08:00', 2015s '2020-01-03 00:00:00-08:00', '... '2020-04-08 00:00:00-07:00', '2020-04-09 00:00:00-07:00'], 2015s dtype='datetime64[ns, US/Pacific]', freq='D') 2015s df = bar a b c ... f g h 2015s foo .....03 00:00:00-05:00 2015s 2020-01-04 00:00:00-08:00 d 4 6 ... d 2013-01-04 2013-01-04 00:00:00-05:00 2015s 2015s [4 rows x 8 columns] 2015s using_infer_string = False 2015s 2015s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 2015s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 2015s index = index_flat 2015s # MultiIndex is tested in test_to_xarray_with_multiindex 2015s if len(index) == 0: 2015s pytest.skip("Test doesn't make sense for empty index") 2015s 2015s from xarray import Dataset 2015s 2015s df.index = index[:4] 2015s df.index.name = "foo" 2015s df.columns.name = "bar" 2015s result = df.to_xarray() 2015s assert result.sizes["foo"] == 4 2015s assert len(result.coords) == 1 2015s assert len(result.data_vars) == 8 2015s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 2015s assert isinstance(result, Dataset) 2015s 2015s # idempotency 2015s # datetimes w/tz are preserved 2015s # column names are lost 2015s expected = df.copy() 2015s # breaks in xarray >= 2024.10.0(?) 2015s # debug print 2015s r0 = result.to_dataframe() 2015s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 2015s expected.columns.name = None 2015s > tm.assert_frame_equal(result.to_dataframe(), expected) 2015s 2015s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: 2015s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2015s 2015s left = Index([2020-01-01 00:00:00-08:00, 2020-01-02 00:00:00-08:00, 2015s 2020-01-03 00:00:00-08:00, 2020-01-04 00:00:00-08:00], 2015s dtype='object', name='foo') 2015s right = DatetimeIndex(['2020-01-01 00:00:00-08:00', '2020-01-02 00:00:00-08:00', 2015s '2020-01-03 00:00:00-08:00', '2020-01-04 00:00:00-08:00'], 2015s dtype='datetime64[ns, US/Pacific]', name='foo', freq='D') 2015s obj = 'DataFrame.index' 2015s 2015s def _check_types(left, right, obj: str = "Index") -> None: 2015s if not exact: 2015s return 2015s 2015s > assert_class_equal(left, right, exact=exact, obj=obj) 2015s E AssertionError: DataFrame.index are different 2015s E 2015s E DataFrame.index classes are different 2015s E [left]: Index([2020-01-01 00:00:00-08:00, 2020-01-02 00:00:00-08:00, 2015s E 2020-01-03 00:00:00-08:00, 2020-01-04 00:00:00-08:00], 2015s E dtype='object', name='foo') 2015s E [right]: DatetimeIndex(['2020-01-01 00:00:00-08:00', '2020-01-02 00:00:00-08:00', 2015s E '2020-01-03 00:00:00-08:00', '2020-01-04 00:00:00-08:00'], 2015s E dtype='datetime64[ns, US/Pacific]', name='foo', freq='D') 2015s 2015s /usr/lib/python3/dist-packages/pandas/_testing/asserters.py:235: AssertionError 2015s ________ TestDataFrameToXArray.test_to_xarray_index_types[bool-object] _________ 2015s self = 2015s index_flat = Index([True, False, True, False, True, False, True, False, True, False], dtype='object') 2015s df = bar a b c d e f g h 2015s foo ... 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 2015s False d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 2015s using_infer_string = False 2015s 2015s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 2015s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 2015s index = index_flat 2015s # MultiIndex is tested in test_to_xarray_with_multiindex 2015s if len(index) == 0: 2015s pytest.skip("Test doesn't make sense for empty index") 2015s 2015s from xarray import Dataset 2015s 2015s df.index = index[:4] 2015s df.index.name = "foo" 2015s df.columns.name = "bar" 2015s result = df.to_xarray() 2015s assert result.sizes["foo"] == 4 2015s assert len(result.coords) == 1 2015s assert len(result.data_vars) == 8 2015s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 2015s assert isinstance(result, Dataset) 2015s 2015s # idempotency 2015s # datetimes w/tz are preserved 2015s # column names are lost 2015s expected = df.copy() 2015s # breaks in xarray >= 2024.10.0(?) 2015s # debug print 2015s r0 = result.to_dataframe() 2015s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 2015s expected.columns.name = None 2015s > tm.assert_frame_equal(result.to_dataframe(), expected) 2015s E AssertionError: DataFrame are different 2015s E 2015s E DataFrame shape mismatch 2015s E [left]: (8, 8) 2015s E [right]: (4, 8) 2015s 2015s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: AssertionError 2015s _________ TestDataFrameToXArray.test_to_xarray_index_types[bool-dtype] _________ 2015s self = 2015s index_flat = Index([True, False, True, False, True, False, True, False, True, False], dtype='bool') 2015s df = bar a b c d e f g h 2015s foo ... 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 2015s False d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 2015s using_infer_string = False 2015s 2015s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 2015s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 2015s index = index_flat 2015s # MultiIndex is tested in test_to_xarray_with_multiindex 2015s if len(index) == 0: 2015s pytest.skip("Test doesn't make sense for empty index") 2015s 2015s from xarray import Dataset 2015s 2015s df.index = index[:4] 2015s df.index.name = "foo" 2015s df.columns.name = "bar" 2015s result = df.to_xarray() 2015s assert result.sizes["foo"] == 4 2015s assert len(result.coords) == 1 2015s assert len(result.data_vars) == 8 2015s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 2015s assert isinstance(result, Dataset) 2015s 2015s # idempotency 2015s # datetimes w/tz are preserved 2015s # column names are lost 2015s expected = df.copy() 2015s # breaks in xarray >= 2024.10.0(?) 2015s # debug print 2015s r0 = result.to_dataframe() 2015s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 2015s expected.columns.name = None 2015s > tm.assert_frame_equal(result.to_dataframe(), expected) 2015s E AssertionError: DataFrame are different 2015s E 2015s E DataFrame shape mismatch 2015s E [left]: (8, 8) 2015s E [right]: (4, 8) 2015s 2015s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: AssertionError 2015s ________ TestDataFrameToXArray.test_to_xarray_index_types[categorical] _________ 2015s self = 2015s index_flat = CategoricalIndex(['a', 'b', 'c', 'd', 'a', 'b', 'c', 'd', 'a', 'b', 'c', 'd', 2015s 'a', 'b', 'c', 'd', 'a... 'a', 'b', 'c', 'd'], 2015s categories=['a', 'b', 'c', 'd'], ordered=False, dtype='category') 2015s df = bar a b c d e f g h 2015s foo ... 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 2015s d d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 2015s using_infer_string = False 2015s 2015s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 2015s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 2015s index = index_flat 2015s # MultiIndex is tested in test_to_xarray_with_multiindex 2015s if len(index) == 0: 2015s pytest.skip("Test doesn't make sense for empty index") 2015s 2015s from xarray import Dataset 2015s 2015s df.index = index[:4] 2015s df.index.name = "foo" 2015s df.columns.name = "bar" 2015s result = df.to_xarray() 2015s assert result.sizes["foo"] == 4 2015s assert len(result.coords) == 1 2015s assert len(result.data_vars) == 8 2015s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 2015s assert isinstance(result, Dataset) 2015s 2015s # idempotency 2015s # datetimes w/tz are preserved 2015s # column names are lost 2015s expected = df.copy() 2015s # breaks in xarray >= 2024.10.0(?) 2015s # debug print 2015s r0 = result.to_dataframe() 2015s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 2015s expected.columns.name = None 2015s > tm.assert_frame_equal(result.to_dataframe(), expected) 2015s 2015s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: 2015s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2015s 2015s left = Index(['a', 'b', 'c', 'd'], dtype='object', name='foo') 2015s right = CategoricalIndex(['a', 'b', 'c', 'd'], categories=['a', 'b', 'c', 'd'], ordered=False, dtype='category', name='foo') 2015s obj = 'DataFrame.index' 2015s 2015s def _check_types(left, right, obj: str = "Index") -> None: 2015s if not exact: 2015s return 2015s 2015s > assert_class_equal(left, right, exact=exact, obj=obj) 2015s E AssertionError: DataFrame.index are different 2015s E 2015s E DataFrame.index classes are different 2015s E [left]: Index(['a', 'b', 'c', 'd'], dtype='object', name='foo') 2015s E [right]: CategoricalIndex(['a', 'b', 'c', 'd'], categories=['a', 'b', 'c', 'd'], ordered=False, dtype='category', name='foo') 2015s 2015s /usr/lib/python3/dist-packages/pandas/_testing/asserters.py:235: AssertionError 2015s __________ TestDataFrameToXArray.test_to_xarray_index_types[repeats] ___________ 2015s self = 2015s index_flat = Index([0, 0, 1, 1, 2, 2], dtype='int64') 2015s df = bar a b c d e f g h 2015s foo ... 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 2015s 1 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 2015s using_infer_string = False 2015s 2015s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 2015s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 2015s index = index_flat 2015s # MultiIndex is tested in test_to_xarray_with_multiindex 2015s if len(index) == 0: 2015s pytest.skip("Test doesn't make sense for empty index") 2015s 2015s from xarray import Dataset 2015s 2015s df.index = index[:4] 2015s df.index.name = "foo" 2015s df.columns.name = "bar" 2015s result = df.to_xarray() 2015s assert result.sizes["foo"] == 4 2015s assert len(result.coords) == 1 2015s assert len(result.data_vars) == 8 2015s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 2015s assert isinstance(result, Dataset) 2015s 2015s # idempotency 2015s # datetimes w/tz are preserved 2015s # column names are lost 2015s expected = df.copy() 2015s # breaks in xarray >= 2024.10.0(?) 2015s # debug print 2015s r0 = result.to_dataframe() 2015s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 2015s expected.columns.name = None 2015s > tm.assert_frame_equal(result.to_dataframe(), expected) 2015s E AssertionError: DataFrame are different 2015s E 2015s E DataFrame shape mismatch 2015s E [left]: (8, 8) 2015s E [right]: (4, 8) 2015s 2015s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: AssertionError 2015s ________ TestDataFrameToXArray.test_to_xarray_index_types[nullable_int] ________ 2015s self = 2015s index_flat = Index([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 2015s 18, 19, 20, 21, 22, 23, 24, 25, ...7, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 2015s 90, 91, 92, 93, 94, 95, 96, 97, 98, 99], 2015s dtype='Int64') 2015s df = bar a b c d e f g h 2015s foo ... 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 2015s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 2015s using_infer_string = False 2015s 2015s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 2015s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 2015s index = index_flat 2015s # MultiIndex is tested in test_to_xarray_with_multiindex 2015s if len(index) == 0: 2015s pytest.skip("Test doesn't make sense for empty index") 2015s 2015s from xarray import Dataset 2015s 2015s df.index = index[:4] 2015s df.index.name = "foo" 2015s df.columns.name = "bar" 2015s result = df.to_xarray() 2015s assert result.sizes["foo"] == 4 2015s assert len(result.coords) == 1 2015s assert len(result.data_vars) == 8 2015s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 2015s assert isinstance(result, Dataset) 2015s 2015s # idempotency 2015s # datetimes w/tz are preserved 2015s # column names are lost 2015s expected = df.copy() 2015s # breaks in xarray >= 2024.10.0(?) 2015s # debug print 2015s r0 = result.to_dataframe() 2015s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 2015s expected.columns.name = None 2015s > tm.assert_frame_equal(result.to_dataframe(), expected) 2015s 2015s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: 2015s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2015s 2015s left = Index([0, 1, 2, 3], dtype='object', name='foo') 2015s right = Index([0, 1, 2, 3], dtype='Int64', name='foo'), obj = 'DataFrame.index' 2015s 2015s def _check_types(left, right, obj: str = "Index") -> None: 2015s if not exact: 2015s return 2015s 2015s assert_class_equal(left, right, exact=exact, obj=obj) 2015s assert_attr_equal("inferred_type", left, right, obj=obj) 2015s 2015s # Skip exact dtype checking when `check_categorical` is False 2015s if isinstance(left.dtype, CategoricalDtype) and isinstance( 2015s right.dtype, CategoricalDtype 2015s ): 2015s if check_categorical: 2015s assert_attr_equal("dtype", left, right, obj=obj) 2015s assert_index_equal(left.categories, right.categories, exact=exact) 2015s return 2015s 2015s > assert_attr_equal("dtype", left, right, obj=obj) 2015s E AssertionError: DataFrame.index are different 2015s E 2015s E Attribute "dtype" are different 2015s E [left]: object 2015s E [right]: Int64 2015s 2015s /usr/lib/python3/dist-packages/pandas/_testing/asserters.py:247: AssertionError 2015s _______ TestDataFrameToXArray.test_to_xarray_index_types[nullable_uint] ________ 2015s self = 2015s index_flat = Index([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 2015s 18, 19, 20, 21, 22, 23, 24, 25, ..., 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 2015s 90, 91, 92, 93, 94, 95, 96, 97, 98, 99], 2015s dtype='UInt16') 2015s df = bar a b c d e f g h 2015s foo ... 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 2015s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 2015s using_infer_string = False 2015s 2015s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 2015s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 2015s index = index_flat 2015s # MultiIndex is tested in test_to_xarray_with_multiindex 2015s if len(index) == 0: 2015s pytest.skip("Test doesn't make sense for empty index") 2015s 2015s from xarray import Dataset 2015s 2015s df.index = index[:4] 2015s df.index.name = "foo" 2015s df.columns.name = "bar" 2015s result = df.to_xarray() 2015s assert result.sizes["foo"] == 4 2015s assert len(result.coords) == 1 2015s assert len(result.data_vars) == 8 2015s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 2015s assert isinstance(result, Dataset) 2015s 2015s # idempotency 2015s # datetimes w/tz are preserved 2015s # column names are lost 2015s expected = df.copy() 2015s # breaks in xarray >= 2024.10.0(?) 2015s # debug print 2015s r0 = result.to_dataframe() 2015s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 2015s expected.columns.name = None 2015s > tm.assert_frame_equal(result.to_dataframe(), expected) 2015s 2015s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: 2015s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2015s 2015s left = Index([0, 1, 2, 3], dtype='object', name='foo') 2015s right = Index([0, 1, 2, 3], dtype='UInt16', name='foo'), obj = 'DataFrame.index' 2015s 2015s def _check_types(left, right, obj: str = "Index") -> None: 2015s if not exact: 2015s return 2015s 2015s assert_class_equal(left, right, exact=exact, obj=obj) 2015s assert_attr_equal("inferred_type", left, right, obj=obj) 2015s 2015s # Skip exact dtype checking when `check_categorical` is False 2015s if isinstance(left.dtype, CategoricalDtype) and isinstance( 2015s right.dtype, CategoricalDtype 2015s ): 2015s if check_categorical: 2015s assert_attr_equal("dtype", left, right, obj=obj) 2015s assert_index_equal(left.categories, right.categories, exact=exact) 2015s return 2015s 2015s > assert_attr_equal("dtype", left, right, obj=obj) 2015s E AssertionError: DataFrame.index are different 2015s E 2015s E Attribute "dtype" are different 2015s E [left]: object 2015s E [right]: UInt16 2015s 2015s /usr/lib/python3/dist-packages/pandas/_testing/asserters.py:247: AssertionError 2015s _______ TestDataFrameToXArray.test_to_xarray_index_types[nullable_float] _______ 2015s self = 2015s 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, 2015s 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, 2015s 96.0, 97.0, 98.0, 99.0], 2015s dtype='Float32') 2015s df = bar a b c d e f g h 2015s foo ... 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 2015s 3.0 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 2015s using_infer_string = False 2015s 2015s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 2015s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 2015s index = index_flat 2015s # MultiIndex is tested in test_to_xarray_with_multiindex 2015s if len(index) == 0: 2015s pytest.skip("Test doesn't make sense for empty index") 2015s 2015s from xarray import Dataset 2015s 2015s df.index = index[:4] 2015s df.index.name = "foo" 2015s df.columns.name = "bar" 2015s result = df.to_xarray() 2015s assert result.sizes["foo"] == 4 2015s assert len(result.coords) == 1 2015s assert len(result.data_vars) == 8 2015s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 2015s assert isinstance(result, Dataset) 2015s 2015s # idempotency 2015s # datetimes w/tz are preserved 2015s # column names are lost 2015s expected = df.copy() 2015s # breaks in xarray >= 2024.10.0(?) 2015s # debug print 2015s r0 = result.to_dataframe() 2015s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 2015s expected.columns.name = None 2015s > tm.assert_frame_equal(result.to_dataframe(), expected) 2015s 2015s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: 2015s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2015s 2015s left = Index([0.0, 1.0, 2.0, 3.0], dtype='object', name='foo') 2015s right = Index([0.0, 1.0, 2.0, 3.0], dtype='Float32', name='foo') 2015s obj = 'DataFrame.index' 2015s 2015s def _check_types(left, right, obj: str = "Index") -> None: 2015s if not exact: 2015s return 2015s 2015s assert_class_equal(left, right, exact=exact, obj=obj) 2015s assert_attr_equal("inferred_type", left, right, obj=obj) 2015s 2015s # Skip exact dtype checking when `check_categorical` is False 2015s if isinstance(left.dtype, CategoricalDtype) and isinstance( 2015s right.dtype, CategoricalDtype 2015s ): 2015s if check_categorical: 2015s assert_attr_equal("dtype", left, right, obj=obj) 2015s assert_index_equal(left.categories, right.categories, exact=exact) 2015s return 2015s 2015s > assert_attr_equal("dtype", left, right, obj=obj) 2015s E AssertionError: DataFrame.index are different 2015s E 2015s E Attribute "dtype" are different 2015s E [left]: object 2015s E [right]: Float32 2015s 2015s /usr/lib/python3/dist-packages/pandas/_testing/asserters.py:247: AssertionError 2016s _______ TestDataFrameToXArray.test_to_xarray_index_types[nullable_bool] ________ 2016s self = 2016s index_flat = Index([False, True, True, True, True, True, True, True, True, True, 2016s True, True, True, True, True,...rue, True, True, 2016s True, True, True, True, True, True, True, True, True, True], 2016s dtype='boolean') 2016s df = bar a b c d e f g h 2016s foo ... 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 2016s True d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 2016s using_infer_string = False 2016s 2016s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 2016s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 2016s index = index_flat 2016s # MultiIndex is tested in test_to_xarray_with_multiindex 2016s if len(index) == 0: 2016s pytest.skip("Test doesn't make sense for empty index") 2016s 2016s from xarray import Dataset 2016s 2016s df.index = index[:4] 2016s df.index.name = "foo" 2016s df.columns.name = "bar" 2016s result = df.to_xarray() 2016s assert result.sizes["foo"] == 4 2016s assert len(result.coords) == 1 2016s assert len(result.data_vars) == 8 2016s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 2016s assert isinstance(result, Dataset) 2016s 2016s # idempotency 2016s # datetimes w/tz are preserved 2016s # column names are lost 2016s expected = df.copy() 2016s # breaks in xarray >= 2024.10.0(?) 2016s # debug print 2016s r0 = result.to_dataframe() 2016s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 2016s expected.columns.name = None 2016s > tm.assert_frame_equal(result.to_dataframe(), expected) 2016s E AssertionError: DataFrame are different 2016s E 2016s E DataFrame shape mismatch 2016s E [left]: (10, 8) 2016s E [right]: (4, 8) 2016s 2016s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: AssertionError 2016s _______ TestDataFrameToXArray.test_to_xarray_index_types[string-python] ________ 2016s self = 2016s index_flat = Index(['pandas_0', 'pandas_1', 'pandas_2', 'pandas_3', 'pandas_4', 'pandas_5', 2016s 'pandas_6', 'pandas_7', 'pandas_...pandas_93', 'pandas_94', 'pandas_95', 2016s 'pandas_96', 'pandas_97', 'pandas_98', 'pandas_99'], 2016s dtype='string') 2016s df = bar a b c d e f g h 2016s foo ....0 True c 2013-01-03 2013-01-03 00:00:00-05:00 2016s pandas_3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 2016s using_infer_string = False 2016s 2016s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 2016s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 2016s index = index_flat 2016s # MultiIndex is tested in test_to_xarray_with_multiindex 2016s if len(index) == 0: 2016s pytest.skip("Test doesn't make sense for empty index") 2016s 2016s from xarray import Dataset 2016s 2016s df.index = index[:4] 2016s df.index.name = "foo" 2016s df.columns.name = "bar" 2016s result = df.to_xarray() 2016s assert result.sizes["foo"] == 4 2016s assert len(result.coords) == 1 2016s assert len(result.data_vars) == 8 2016s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 2016s assert isinstance(result, Dataset) 2016s 2016s # idempotency 2016s # datetimes w/tz are preserved 2016s # column names are lost 2016s expected = df.copy() 2016s # breaks in xarray >= 2024.10.0(?) 2016s # debug print 2016s r0 = result.to_dataframe() 2016s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 2016s expected.columns.name = None 2016s > tm.assert_frame_equal(result.to_dataframe(), expected) 2016s 2016s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: 2016s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2016s 2016s left = Index(['pandas_0', 'pandas_1', 'pandas_2', 'pandas_3'], dtype='object', name='foo') 2016s right = Index(['pandas_0', 'pandas_1', 'pandas_2', 'pandas_3'], dtype='string', name='foo') 2016s obj = 'DataFrame.index' 2016s 2016s def _check_types(left, right, obj: str = "Index") -> None: 2016s if not exact: 2016s return 2016s 2016s assert_class_equal(left, right, exact=exact, obj=obj) 2016s assert_attr_equal("inferred_type", left, right, obj=obj) 2016s 2016s # Skip exact dtype checking when `check_categorical` is False 2016s if isinstance(left.dtype, CategoricalDtype) and isinstance( 2016s right.dtype, CategoricalDtype 2016s ): 2016s if check_categorical: 2016s assert_attr_equal("dtype", left, right, obj=obj) 2016s assert_index_equal(left.categories, right.categories, exact=exact) 2016s return 2016s 2016s > assert_attr_equal("dtype", left, right, obj=obj) 2016s E AssertionError: DataFrame.index are different 2016s E 2016s E Attribute "dtype" are different 2016s E [left]: object 2016s E [right]: string[python] 2016s 2016s /usr/lib/python3/dist-packages/pandas/_testing/asserters.py:247: AssertionError 2016s =============================== warnings summary =============================== 2016s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:39 2016s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:39: PytestUnknownMarkWarning: Unknown pytest.mark.single_cpu - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html 2016s pytestmark = pytest.mark.single_cpu 2016s 2016s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_append.py:30 2016s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_append.py:30: PytestUnknownMarkWarning: Unknown pytest.mark.single_cpu - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html 2016s pytestmark = pytest.mark.single_cpu 2016s 2016s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_store.py:39 2016s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_store.py:39: PytestUnknownMarkWarning: Unknown pytest.mark.single_cpu - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html 2016s pytestmark = pytest.mark.single_cpu 2016s 2016s ../../../usr/lib/python3/dist-packages/pandas/tests/test_downstream.py:119 2016s /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 2016s @pytest.mark.single_cpu 2016s 2016s ../../../usr/lib/python3/dist-packages/pandas/tests/test_downstream.py:125 2016s /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 2016s @pytest.mark.single_cpu 2016s 2016s ../../../usr/lib/python3/dist-packages/pandas/tests/test_downstream.py:196 2016s /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 2016s @pytest.mark.single_cpu 2016s 2016s io/pytables/test_file_handling.py: 191 warnings 2016s io/pytables/test_append.py: 21 warnings 2016s io/pytables/test_store.py: 66 warnings 2016s test_downstream.py: 26 warnings 2016s generic/test_to_xarray.py: 62 warnings 2016s /usr/lib/python3/dist-packages/py/_process/forkedfunc.py:45: DeprecationWarning: This process (pid=16524) is multi-threaded, use of fork() may lead to deadlocks in the child. 2016s pid = os.fork() 2016s 2016s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 2016s /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-32iquh4p' 2016s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 2016s 2016s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:429 2016s /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-zc6de7qg' 2016s config.cache.set("cache/lastfailed", self.lastfailed) 2016s 2016s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 2016s /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-6q5z71c5' 2016s session.config.cache.set(STEPWISE_CACHE_DIR, []) 2016s 2016s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 2016s =========================== short test summary info ============================ 2016s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-1] 2016s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-2] 2016s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-3] 2016s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-4] 2016s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-5] 2016s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-6] 2016s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-7] 2016s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-8] 2016s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-9] 2016s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_append.py::test_append_frame_column_oriented 2016s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_store.py::test_select_filter_corner 2016s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/test_downstream.py::test_frame_setitem_dask_array_into_new_col 2016s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[datetime-tz] 2016s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[bool-object] 2016s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[bool-dtype] 2016s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[categorical] 2016s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[repeats] 2016s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[nullable_int] 2016s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[nullable_uint] 2016s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[nullable_float] 2016s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[nullable_bool] 2016s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[string-python] 2016s =========== 22 failed, 335 passed, 9 skipped, 375 warnings in 34.13s =========== 2016s pymysql/psycopg2 tests, which do not work in this test environment 2017s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 2017s 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" 2017s 2017s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 2018s ============================= test session starts ============================== 2018s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 2018s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 2018s rootdir: /usr/lib/python3/dist-packages/pandas/tests 2018s plugins: typeguard-4.4.2, hypothesis-6.127.4, asyncio-0.25.1, forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, qt-4.4.0 2018s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 2018s collected 2513 items 2018s 2760s ../../../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................ 2787s ../../../usr/lib/python3/dist-packages/pandas/tests/tools/test_to_datetime.py ..................................................................................................................................................................................................................................ssssssss......................................................................................................................................................................................................................................................................................................................................................xx..........................................................................................................................................................................................................................................................................................................................................................................ssssssssss............................ 2787s 2787s ==================================== ERRORS ==================================== 2787s _______ ERROR at teardown of test_dataframe_to_sql[mysql_pymysql_engine] _______ 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s > sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3.13/socket.py:864: in create_connection 2787s raise exceptions[0] 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s address = ('localhost', 3306), timeout = 10, source_address = None 2787s 2787s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2787s source_address=None, *, all_errors=False): 2787s """Connect to *address* and return the socket object. 2787s 2787s Convenience function. Connect to *address* (a 2-tuple ``(host, 2787s port)``) and return the socket object. Passing the optional 2787s *timeout* parameter will set the timeout on the socket instance 2787s before attempting to connect. If no *timeout* is supplied, the 2787s global default timeout setting returned by :func:`getdefaulttimeout` 2787s is used. If *source_address* is set it must be a tuple of (host, port) 2787s for the socket to bind as a source address before making the connection. 2787s A host of '' or port 0 tells the OS to use the default. When a connection 2787s cannot be created, raises the last error if *all_errors* is False, 2787s and an ExceptionGroup of all errors if *all_errors* is True. 2787s """ 2787s 2787s host, port = address 2787s exceptions = [] 2787s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2787s af, socktype, proto, canonname, sa = res 2787s sock = None 2787s try: 2787s sock = socket(af, socktype, proto) 2787s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2787s sock.settimeout(timeout) 2787s if source_address: 2787s sock.bind(source_address) 2787s > sock.connect(sa) 2787s E ConnectionRefusedError: [Errno 111] Connection refused 2787s 2787s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2787s 2787s During handling of the above exception, another exception occurred: 2787s 2787s self = 2787s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2787s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def mysql_pymysql_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s pymysql = td.versioned_importorskip("pymysql") 2787s engine = sqlalchemy.create_engine( 2787s "mysql+pymysql://root@localhost:3306/pandas", 2787s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s ________ ERROR at teardown of test_dataframe_to_sql[mysql_pymysql_conn] ________ 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s > sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3.13/socket.py:864: in create_connection 2787s raise exceptions[0] 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s address = ('localhost', 3306), timeout = 10, source_address = None 2787s 2787s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2787s source_address=None, *, all_errors=False): 2787s """Connect to *address* and return the socket object. 2787s 2787s Convenience function. Connect to *address* (a 2-tuple ``(host, 2787s port)``) and return the socket object. Passing the optional 2787s *timeout* parameter will set the timeout on the socket instance 2787s before attempting to connect. If no *timeout* is supplied, the 2787s global default timeout setting returned by :func:`getdefaulttimeout` 2787s is used. If *source_address* is set it must be a tuple of (host, port) 2787s for the socket to bind as a source address before making the connection. 2787s A host of '' or port 0 tells the OS to use the default. When a connection 2787s cannot be created, raises the last error if *all_errors* is False, 2787s and an ExceptionGroup of all errors if *all_errors* is True. 2787s """ 2787s 2787s host, port = address 2787s exceptions = [] 2787s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2787s af, socktype, proto, canonname, sa = res 2787s sock = None 2787s try: 2787s sock = socket(af, socktype, proto) 2787s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2787s sock.settimeout(timeout) 2787s if source_address: 2787s sock.bind(source_address) 2787s > sock.connect(sa) 2787s E ConnectionRefusedError: [Errno 111] Connection refused 2787s 2787s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2787s 2787s During handling of the above exception, another exception occurred: 2787s 2787s self = 2787s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2787s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def mysql_pymysql_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s pymysql = td.versioned_importorskip("pymysql") 2787s engine = sqlalchemy.create_engine( 2787s "mysql+pymysql://root@localhost:3306/pandas", 2787s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s ____ ERROR at teardown of test_dataframe_to_sql[postgresql_psycopg2_engine] ____ 2787s self = 2787s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2787s connection = None, _has_events = None, _allow_revalidate = True 2787s _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def postgresql_psycopg2_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s td.versioned_importorskip("psycopg2") 2787s engine = sqlalchemy.create_engine( 2787s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s E 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s _____ ERROR at teardown of test_dataframe_to_sql[postgresql_psycopg2_conn] _____ 2787s self = 2787s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2787s connection = None, _has_events = None, _allow_revalidate = True 2787s _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def postgresql_psycopg2_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s td.versioned_importorskip("psycopg2") 2787s engine = sqlalchemy.create_engine( 2787s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s E 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s ____ ERROR at teardown of test_dataframe_to_sql_empty[mysql_pymysql_engine] ____ 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s > sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3.13/socket.py:864: in create_connection 2787s raise exceptions[0] 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s address = ('localhost', 3306), timeout = 10, source_address = None 2787s 2787s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2787s source_address=None, *, all_errors=False): 2787s """Connect to *address* and return the socket object. 2787s 2787s Convenience function. Connect to *address* (a 2-tuple ``(host, 2787s port)``) and return the socket object. Passing the optional 2787s *timeout* parameter will set the timeout on the socket instance 2787s before attempting to connect. If no *timeout* is supplied, the 2787s global default timeout setting returned by :func:`getdefaulttimeout` 2787s is used. If *source_address* is set it must be a tuple of (host, port) 2787s for the socket to bind as a source address before making the connection. 2787s A host of '' or port 0 tells the OS to use the default. When a connection 2787s cannot be created, raises the last error if *all_errors* is False, 2787s and an ExceptionGroup of all errors if *all_errors* is True. 2787s """ 2787s 2787s host, port = address 2787s exceptions = [] 2787s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2787s af, socktype, proto, canonname, sa = res 2787s sock = None 2787s try: 2787s sock = socket(af, socktype, proto) 2787s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2787s sock.settimeout(timeout) 2787s if source_address: 2787s sock.bind(source_address) 2787s > sock.connect(sa) 2787s E ConnectionRefusedError: [Errno 111] Connection refused 2787s 2787s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2787s 2787s During handling of the above exception, another exception occurred: 2787s 2787s self = 2787s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2787s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def mysql_pymysql_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s pymysql = td.versioned_importorskip("pymysql") 2787s engine = sqlalchemy.create_engine( 2787s "mysql+pymysql://root@localhost:3306/pandas", 2787s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s _____ ERROR at teardown of test_dataframe_to_sql_empty[mysql_pymysql_conn] _____ 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s > sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3.13/socket.py:864: in create_connection 2787s raise exceptions[0] 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s address = ('localhost', 3306), timeout = 10, source_address = None 2787s 2787s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2787s source_address=None, *, all_errors=False): 2787s """Connect to *address* and return the socket object. 2787s 2787s Convenience function. Connect to *address* (a 2-tuple ``(host, 2787s port)``) and return the socket object. Passing the optional 2787s *timeout* parameter will set the timeout on the socket instance 2787s before attempting to connect. If no *timeout* is supplied, the 2787s global default timeout setting returned by :func:`getdefaulttimeout` 2787s is used. If *source_address* is set it must be a tuple of (host, port) 2787s for the socket to bind as a source address before making the connection. 2787s A host of '' or port 0 tells the OS to use the default. When a connection 2787s cannot be created, raises the last error if *all_errors* is False, 2787s and an ExceptionGroup of all errors if *all_errors* is True. 2787s """ 2787s 2787s host, port = address 2787s exceptions = [] 2787s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2787s af, socktype, proto, canonname, sa = res 2787s sock = None 2787s try: 2787s sock = socket(af, socktype, proto) 2787s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2787s sock.settimeout(timeout) 2787s if source_address: 2787s sock.bind(source_address) 2787s > sock.connect(sa) 2787s E ConnectionRefusedError: [Errno 111] Connection refused 2787s 2787s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2787s 2787s During handling of the above exception, another exception occurred: 2787s 2787s self = 2787s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2787s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def mysql_pymysql_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s pymysql = td.versioned_importorskip("pymysql") 2787s engine = sqlalchemy.create_engine( 2787s "mysql+pymysql://root@localhost:3306/pandas", 2787s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s _ ERROR at teardown of test_dataframe_to_sql_empty[postgresql_psycopg2_engine] _ 2787s self = 2787s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2787s connection = None, _has_events = None, _allow_revalidate = True 2787s _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def postgresql_psycopg2_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s td.versioned_importorskip("psycopg2") 2787s engine = sqlalchemy.create_engine( 2787s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s E 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s __ ERROR at teardown of test_dataframe_to_sql_empty[postgresql_psycopg2_conn] __ 2787s self = 2787s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2787s connection = None, _has_events = None, _allow_revalidate = True 2787s _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def postgresql_psycopg2_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s td.versioned_importorskip("psycopg2") 2787s engine = sqlalchemy.create_engine( 2787s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s E 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s _________ ERROR at teardown of test_to_sql[None-mysql_pymysql_engine] __________ 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s > sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3.13/socket.py:864: in create_connection 2787s raise exceptions[0] 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s address = ('localhost', 3306), timeout = 10, source_address = None 2787s 2787s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2787s source_address=None, *, all_errors=False): 2787s """Connect to *address* and return the socket object. 2787s 2787s Convenience function. Connect to *address* (a 2-tuple ``(host, 2787s port)``) and return the socket object. Passing the optional 2787s *timeout* parameter will set the timeout on the socket instance 2787s before attempting to connect. If no *timeout* is supplied, the 2787s global default timeout setting returned by :func:`getdefaulttimeout` 2787s is used. If *source_address* is set it must be a tuple of (host, port) 2787s for the socket to bind as a source address before making the connection. 2787s A host of '' or port 0 tells the OS to use the default. When a connection 2787s cannot be created, raises the last error if *all_errors* is False, 2787s and an ExceptionGroup of all errors if *all_errors* is True. 2787s """ 2787s 2787s host, port = address 2787s exceptions = [] 2787s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2787s af, socktype, proto, canonname, sa = res 2787s sock = None 2787s try: 2787s sock = socket(af, socktype, proto) 2787s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2787s sock.settimeout(timeout) 2787s if source_address: 2787s sock.bind(source_address) 2787s > sock.connect(sa) 2787s E ConnectionRefusedError: [Errno 111] Connection refused 2787s 2787s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2787s 2787s During handling of the above exception, another exception occurred: 2787s 2787s self = 2787s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2787s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def mysql_pymysql_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s pymysql = td.versioned_importorskip("pymysql") 2787s engine = sqlalchemy.create_engine( 2787s "mysql+pymysql://root@localhost:3306/pandas", 2787s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s __________ ERROR at teardown of test_to_sql[None-mysql_pymysql_conn] ___________ 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s > sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3.13/socket.py:864: in create_connection 2787s raise exceptions[0] 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s address = ('localhost', 3306), timeout = 10, source_address = None 2787s 2787s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2787s source_address=None, *, all_errors=False): 2787s """Connect to *address* and return the socket object. 2787s 2787s Convenience function. Connect to *address* (a 2-tuple ``(host, 2787s port)``) and return the socket object. Passing the optional 2787s *timeout* parameter will set the timeout on the socket instance 2787s before attempting to connect. If no *timeout* is supplied, the 2787s global default timeout setting returned by :func:`getdefaulttimeout` 2787s is used. If *source_address* is set it must be a tuple of (host, port) 2787s for the socket to bind as a source address before making the connection. 2787s A host of '' or port 0 tells the OS to use the default. When a connection 2787s cannot be created, raises the last error if *all_errors* is False, 2787s and an ExceptionGroup of all errors if *all_errors* is True. 2787s """ 2787s 2787s host, port = address 2787s exceptions = [] 2787s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2787s af, socktype, proto, canonname, sa = res 2787s sock = None 2787s try: 2787s sock = socket(af, socktype, proto) 2787s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2787s sock.settimeout(timeout) 2787s if source_address: 2787s sock.bind(source_address) 2787s > sock.connect(sa) 2787s E ConnectionRefusedError: [Errno 111] Connection refused 2787s 2787s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2787s 2787s During handling of the above exception, another exception occurred: 2787s 2787s self = 2787s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2787s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def mysql_pymysql_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s pymysql = td.versioned_importorskip("pymysql") 2787s engine = sqlalchemy.create_engine( 2787s "mysql+pymysql://root@localhost:3306/pandas", 2787s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s ______ ERROR at teardown of test_to_sql[None-postgresql_psycopg2_engine] _______ 2787s self = 2787s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2787s connection = None, _has_events = None, _allow_revalidate = True 2787s _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def postgresql_psycopg2_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s td.versioned_importorskip("psycopg2") 2787s engine = sqlalchemy.create_engine( 2787s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s E 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s _______ ERROR at teardown of test_to_sql[None-postgresql_psycopg2_conn] ________ 2787s self = 2787s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2787s connection = None, _has_events = None, _allow_revalidate = True 2787s _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def postgresql_psycopg2_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s td.versioned_importorskip("psycopg2") 2787s engine = sqlalchemy.create_engine( 2787s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s E 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s _________ ERROR at teardown of test_to_sql[multi-mysql_pymysql_engine] _________ 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s > sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3.13/socket.py:864: in create_connection 2787s raise exceptions[0] 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s address = ('localhost', 3306), timeout = 10, source_address = None 2787s 2787s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2787s source_address=None, *, all_errors=False): 2787s """Connect to *address* and return the socket object. 2787s 2787s Convenience function. Connect to *address* (a 2-tuple ``(host, 2787s port)``) and return the socket object. Passing the optional 2787s *timeout* parameter will set the timeout on the socket instance 2787s before attempting to connect. If no *timeout* is supplied, the 2787s global default timeout setting returned by :func:`getdefaulttimeout` 2787s is used. If *source_address* is set it must be a tuple of (host, port) 2787s for the socket to bind as a source address before making the connection. 2787s A host of '' or port 0 tells the OS to use the default. When a connection 2787s cannot be created, raises the last error if *all_errors* is False, 2787s and an ExceptionGroup of all errors if *all_errors* is True. 2787s """ 2787s 2787s host, port = address 2787s exceptions = [] 2787s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2787s af, socktype, proto, canonname, sa = res 2787s sock = None 2787s try: 2787s sock = socket(af, socktype, proto) 2787s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2787s sock.settimeout(timeout) 2787s if source_address: 2787s sock.bind(source_address) 2787s > sock.connect(sa) 2787s E ConnectionRefusedError: [Errno 111] Connection refused 2787s 2787s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2787s 2787s During handling of the above exception, another exception occurred: 2787s 2787s self = 2787s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2787s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def mysql_pymysql_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s pymysql = td.versioned_importorskip("pymysql") 2787s engine = sqlalchemy.create_engine( 2787s "mysql+pymysql://root@localhost:3306/pandas", 2787s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s __________ ERROR at teardown of test_to_sql[multi-mysql_pymysql_conn] __________ 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s > sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3.13/socket.py:864: in create_connection 2787s raise exceptions[0] 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s address = ('localhost', 3306), timeout = 10, source_address = None 2787s 2787s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2787s source_address=None, *, all_errors=False): 2787s """Connect to *address* and return the socket object. 2787s 2787s Convenience function. Connect to *address* (a 2-tuple ``(host, 2787s port)``) and return the socket object. Passing the optional 2787s *timeout* parameter will set the timeout on the socket instance 2787s before attempting to connect. If no *timeout* is supplied, the 2787s global default timeout setting returned by :func:`getdefaulttimeout` 2787s is used. If *source_address* is set it must be a tuple of (host, port) 2787s for the socket to bind as a source address before making the connection. 2787s A host of '' or port 0 tells the OS to use the default. When a connection 2787s cannot be created, raises the last error if *all_errors* is False, 2787s and an ExceptionGroup of all errors if *all_errors* is True. 2787s """ 2787s 2787s host, port = address 2787s exceptions = [] 2787s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2787s af, socktype, proto, canonname, sa = res 2787s sock = None 2787s try: 2787s sock = socket(af, socktype, proto) 2787s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2787s sock.settimeout(timeout) 2787s if source_address: 2787s sock.bind(source_address) 2787s > sock.connect(sa) 2787s E ConnectionRefusedError: [Errno 111] Connection refused 2787s 2787s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2787s 2787s During handling of the above exception, another exception occurred: 2787s 2787s self = 2787s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2787s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def mysql_pymysql_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s pymysql = td.versioned_importorskip("pymysql") 2787s engine = sqlalchemy.create_engine( 2787s "mysql+pymysql://root@localhost:3306/pandas", 2787s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s ______ ERROR at teardown of test_to_sql[multi-postgresql_psycopg2_engine] ______ 2787s self = 2787s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2787s connection = None, _has_events = None, _allow_revalidate = True 2787s _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def postgresql_psycopg2_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s td.versioned_importorskip("psycopg2") 2787s engine = sqlalchemy.create_engine( 2787s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s E 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s _______ ERROR at teardown of test_to_sql[multi-postgresql_psycopg2_conn] _______ 2787s self = 2787s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2787s connection = None, _has_events = None, _allow_revalidate = True 2787s _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def postgresql_psycopg2_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s td.versioned_importorskip("psycopg2") 2787s engine = sqlalchemy.create_engine( 2787s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s E 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s ____ ERROR at teardown of test_to_sql_exist[replace-1-mysql_pymysql_engine] ____ 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s > sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3.13/socket.py:864: in create_connection 2787s raise exceptions[0] 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s address = ('localhost', 3306), timeout = 10, source_address = None 2787s 2787s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2787s source_address=None, *, all_errors=False): 2787s """Connect to *address* and return the socket object. 2787s 2787s Convenience function. Connect to *address* (a 2-tuple ``(host, 2787s port)``) and return the socket object. Passing the optional 2787s *timeout* parameter will set the timeout on the socket instance 2787s before attempting to connect. If no *timeout* is supplied, the 2787s global default timeout setting returned by :func:`getdefaulttimeout` 2787s is used. If *source_address* is set it must be a tuple of (host, port) 2787s for the socket to bind as a source address before making the connection. 2787s A host of '' or port 0 tells the OS to use the default. When a connection 2787s cannot be created, raises the last error if *all_errors* is False, 2787s and an ExceptionGroup of all errors if *all_errors* is True. 2787s """ 2787s 2787s host, port = address 2787s exceptions = [] 2787s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2787s af, socktype, proto, canonname, sa = res 2787s sock = None 2787s try: 2787s sock = socket(af, socktype, proto) 2787s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2787s sock.settimeout(timeout) 2787s if source_address: 2787s sock.bind(source_address) 2787s > sock.connect(sa) 2787s E ConnectionRefusedError: [Errno 111] Connection refused 2787s 2787s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2787s 2787s During handling of the above exception, another exception occurred: 2787s 2787s self = 2787s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2787s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def mysql_pymysql_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s pymysql = td.versioned_importorskip("pymysql") 2787s engine = sqlalchemy.create_engine( 2787s "mysql+pymysql://root@localhost:3306/pandas", 2787s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s _____ ERROR at teardown of test_to_sql_exist[replace-1-mysql_pymysql_conn] _____ 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s > sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3.13/socket.py:864: in create_connection 2787s raise exceptions[0] 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s address = ('localhost', 3306), timeout = 10, source_address = None 2787s 2787s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2787s source_address=None, *, all_errors=False): 2787s """Connect to *address* and return the socket object. 2787s 2787s Convenience function. Connect to *address* (a 2-tuple ``(host, 2787s port)``) and return the socket object. Passing the optional 2787s *timeout* parameter will set the timeout on the socket instance 2787s before attempting to connect. If no *timeout* is supplied, the 2787s global default timeout setting returned by :func:`getdefaulttimeout` 2787s is used. If *source_address* is set it must be a tuple of (host, port) 2787s for the socket to bind as a source address before making the connection. 2787s A host of '' or port 0 tells the OS to use the default. When a connection 2787s cannot be created, raises the last error if *all_errors* is False, 2787s and an ExceptionGroup of all errors if *all_errors* is True. 2787s """ 2787s 2787s host, port = address 2787s exceptions = [] 2787s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2787s af, socktype, proto, canonname, sa = res 2787s sock = None 2787s try: 2787s sock = socket(af, socktype, proto) 2787s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2787s sock.settimeout(timeout) 2787s if source_address: 2787s sock.bind(source_address) 2787s > sock.connect(sa) 2787s E ConnectionRefusedError: [Errno 111] Connection refused 2787s 2787s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2787s 2787s During handling of the above exception, another exception occurred: 2787s 2787s self = 2787s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2787s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def mysql_pymysql_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s pymysql = td.versioned_importorskip("pymysql") 2787s engine = sqlalchemy.create_engine( 2787s "mysql+pymysql://root@localhost:3306/pandas", 2787s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s _ ERROR at teardown of test_to_sql_exist[replace-1-postgresql_psycopg2_engine] _ 2787s self = 2787s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2787s connection = None, _has_events = None, _allow_revalidate = True 2787s _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def postgresql_psycopg2_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s td.versioned_importorskip("psycopg2") 2787s engine = sqlalchemy.create_engine( 2787s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s E 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s __ ERROR at teardown of test_to_sql_exist[replace-1-postgresql_psycopg2_conn] __ 2787s self = 2787s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2787s connection = None, _has_events = None, _allow_revalidate = True 2787s _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def postgresql_psycopg2_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s td.versioned_importorskip("psycopg2") 2787s engine = sqlalchemy.create_engine( 2787s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s E 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s ____ ERROR at teardown of test_to_sql_exist[append-2-mysql_pymysql_engine] _____ 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s > sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3.13/socket.py:864: in create_connection 2787s raise exceptions[0] 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s address = ('localhost', 3306), timeout = 10, source_address = None 2787s 2787s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2787s source_address=None, *, all_errors=False): 2787s """Connect to *address* and return the socket object. 2787s 2787s Convenience function. Connect to *address* (a 2-tuple ``(host, 2787s port)``) and return the socket object. Passing the optional 2787s *timeout* parameter will set the timeout on the socket instance 2787s before attempting to connect. If no *timeout* is supplied, the 2787s global default timeout setting returned by :func:`getdefaulttimeout` 2787s is used. If *source_address* is set it must be a tuple of (host, port) 2787s for the socket to bind as a source address before making the connection. 2787s A host of '' or port 0 tells the OS to use the default. When a connection 2787s cannot be created, raises the last error if *all_errors* is False, 2787s and an ExceptionGroup of all errors if *all_errors* is True. 2787s """ 2787s 2787s host, port = address 2787s exceptions = [] 2787s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2787s af, socktype, proto, canonname, sa = res 2787s sock = None 2787s try: 2787s sock = socket(af, socktype, proto) 2787s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2787s sock.settimeout(timeout) 2787s if source_address: 2787s sock.bind(source_address) 2787s > sock.connect(sa) 2787s E ConnectionRefusedError: [Errno 111] Connection refused 2787s 2787s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2787s 2787s During handling of the above exception, another exception occurred: 2787s 2787s self = 2787s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2787s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def mysql_pymysql_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s pymysql = td.versioned_importorskip("pymysql") 2787s engine = sqlalchemy.create_engine( 2787s "mysql+pymysql://root@localhost:3306/pandas", 2787s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s _____ ERROR at teardown of test_to_sql_exist[append-2-mysql_pymysql_conn] ______ 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s > sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3.13/socket.py:864: in create_connection 2787s raise exceptions[0] 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s address = ('localhost', 3306), timeout = 10, source_address = None 2787s 2787s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2787s source_address=None, *, all_errors=False): 2787s """Connect to *address* and return the socket object. 2787s 2787s Convenience function. Connect to *address* (a 2-tuple ``(host, 2787s port)``) and return the socket object. Passing the optional 2787s *timeout* parameter will set the timeout on the socket instance 2787s before attempting to connect. If no *timeout* is supplied, the 2787s global default timeout setting returned by :func:`getdefaulttimeout` 2787s is used. If *source_address* is set it must be a tuple of (host, port) 2787s for the socket to bind as a source address before making the connection. 2787s A host of '' or port 0 tells the OS to use the default. When a connection 2787s cannot be created, raises the last error if *all_errors* is False, 2787s and an ExceptionGroup of all errors if *all_errors* is True. 2787s """ 2787s 2787s host, port = address 2787s exceptions = [] 2787s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2787s af, socktype, proto, canonname, sa = res 2787s sock = None 2787s try: 2787s sock = socket(af, socktype, proto) 2787s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2787s sock.settimeout(timeout) 2787s if source_address: 2787s sock.bind(source_address) 2787s > sock.connect(sa) 2787s E ConnectionRefusedError: [Errno 111] Connection refused 2787s 2787s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2787s 2787s During handling of the above exception, another exception occurred: 2787s 2787s self = 2787s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2787s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def mysql_pymysql_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s pymysql = td.versioned_importorskip("pymysql") 2787s engine = sqlalchemy.create_engine( 2787s "mysql+pymysql://root@localhost:3306/pandas", 2787s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s _ ERROR at teardown of test_to_sql_exist[append-2-postgresql_psycopg2_engine] __ 2787s self = 2787s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2787s connection = None, _has_events = None, _allow_revalidate = True 2787s _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def postgresql_psycopg2_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s td.versioned_importorskip("psycopg2") 2787s engine = sqlalchemy.create_engine( 2787s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s E 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s __ ERROR at teardown of test_to_sql_exist[append-2-postgresql_psycopg2_conn] ___ 2787s self = 2787s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2787s connection = None, _has_events = None, _allow_revalidate = True 2787s _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def postgresql_psycopg2_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s td.versioned_importorskip("psycopg2") 2787s engine = sqlalchemy.create_engine( 2787s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s E 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s ______ ERROR at teardown of test_to_sql_exist_fail[mysql_pymysql_engine] _______ 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s > sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3.13/socket.py:864: in create_connection 2787s raise exceptions[0] 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s address = ('localhost', 3306), timeout = 10, source_address = None 2787s 2787s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2787s source_address=None, *, all_errors=False): 2787s """Connect to *address* and return the socket object. 2787s 2787s Convenience function. Connect to *address* (a 2-tuple ``(host, 2787s port)``) and return the socket object. Passing the optional 2787s *timeout* parameter will set the timeout on the socket instance 2787s before attempting to connect. If no *timeout* is supplied, the 2787s global default timeout setting returned by :func:`getdefaulttimeout` 2787s is used. If *source_address* is set it must be a tuple of (host, port) 2787s for the socket to bind as a source address before making the connection. 2787s A host of '' or port 0 tells the OS to use the default. When a connection 2787s cannot be created, raises the last error if *all_errors* is False, 2787s and an ExceptionGroup of all errors if *all_errors* is True. 2787s """ 2787s 2787s host, port = address 2787s exceptions = [] 2787s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2787s af, socktype, proto, canonname, sa = res 2787s sock = None 2787s try: 2787s sock = socket(af, socktype, proto) 2787s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2787s sock.settimeout(timeout) 2787s if source_address: 2787s sock.bind(source_address) 2787s > sock.connect(sa) 2787s E ConnectionRefusedError: [Errno 111] Connection refused 2787s 2787s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2787s 2787s During handling of the above exception, another exception occurred: 2787s 2787s self = 2787s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2787s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def mysql_pymysql_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s pymysql = td.versioned_importorskip("pymysql") 2787s engine = sqlalchemy.create_engine( 2787s "mysql+pymysql://root@localhost:3306/pandas", 2787s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s _______ ERROR at teardown of test_to_sql_exist_fail[mysql_pymysql_conn] ________ 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s > sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3.13/socket.py:864: in create_connection 2787s raise exceptions[0] 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s address = ('localhost', 3306), timeout = 10, source_address = None 2787s 2787s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2787s source_address=None, *, all_errors=False): 2787s """Connect to *address* and return the socket object. 2787s 2787s Convenience function. Connect to *address* (a 2-tuple ``(host, 2787s port)``) and return the socket object. Passing the optional 2787s *timeout* parameter will set the timeout on the socket instance 2787s before attempting to connect. If no *timeout* is supplied, the 2787s global default timeout setting returned by :func:`getdefaulttimeout` 2787s is used. If *source_address* is set it must be a tuple of (host, port) 2787s for the socket to bind as a source address before making the connection. 2787s A host of '' or port 0 tells the OS to use the default. When a connection 2787s cannot be created, raises the last error if *all_errors* is False, 2787s and an ExceptionGroup of all errors if *all_errors* is True. 2787s """ 2787s 2787s host, port = address 2787s exceptions = [] 2787s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2787s af, socktype, proto, canonname, sa = res 2787s sock = None 2787s try: 2787s sock = socket(af, socktype, proto) 2787s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2787s sock.settimeout(timeout) 2787s if source_address: 2787s sock.bind(source_address) 2787s > sock.connect(sa) 2787s E ConnectionRefusedError: [Errno 111] Connection refused 2787s 2787s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2787s 2787s During handling of the above exception, another exception occurred: 2787s 2787s self = 2787s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2787s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def mysql_pymysql_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s pymysql = td.versioned_importorskip("pymysql") 2787s engine = sqlalchemy.create_engine( 2787s "mysql+pymysql://root@localhost:3306/pandas", 2787s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s ___ ERROR at teardown of test_to_sql_exist_fail[postgresql_psycopg2_engine] ____ 2787s self = 2787s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2787s connection = None, _has_events = None, _allow_revalidate = True 2787s _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def postgresql_psycopg2_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s td.versioned_importorskip("psycopg2") 2787s engine = sqlalchemy.create_engine( 2787s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s E 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s ____ ERROR at teardown of test_to_sql_exist_fail[postgresql_psycopg2_conn] _____ 2787s self = 2787s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2787s connection = None, _has_events = None, _allow_revalidate = True 2787s _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def postgresql_psycopg2_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s td.versioned_importorskip("psycopg2") 2787s engine = sqlalchemy.create_engine( 2787s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s E 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s _____ ERROR at teardown of test_read_iris_query[mysql_pymysql_engine_iris] _____ 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s > sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3.13/socket.py:864: in create_connection 2787s raise exceptions[0] 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s address = ('localhost', 3306), timeout = 10, source_address = None 2787s 2787s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2787s source_address=None, *, all_errors=False): 2787s """Connect to *address* and return the socket object. 2787s 2787s Convenience function. Connect to *address* (a 2-tuple ``(host, 2787s port)``) and return the socket object. Passing the optional 2787s *timeout* parameter will set the timeout on the socket instance 2787s before attempting to connect. If no *timeout* is supplied, the 2787s global default timeout setting returned by :func:`getdefaulttimeout` 2787s is used. If *source_address* is set it must be a tuple of (host, port) 2787s for the socket to bind as a source address before making the connection. 2787s A host of '' or port 0 tells the OS to use the default. When a connection 2787s cannot be created, raises the last error if *all_errors* is False, 2787s and an ExceptionGroup of all errors if *all_errors* is True. 2787s """ 2787s 2787s host, port = address 2787s exceptions = [] 2787s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2787s af, socktype, proto, canonname, sa = res 2787s sock = None 2787s try: 2787s sock = socket(af, socktype, proto) 2787s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2787s sock.settimeout(timeout) 2787s if source_address: 2787s sock.bind(source_address) 2787s > sock.connect(sa) 2787s E ConnectionRefusedError: [Errno 111] Connection refused 2787s 2787s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2787s 2787s During handling of the above exception, another exception occurred: 2787s 2787s self = 2787s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2787s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def mysql_pymysql_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s pymysql = td.versioned_importorskip("pymysql") 2787s engine = sqlalchemy.create_engine( 2787s "mysql+pymysql://root@localhost:3306/pandas", 2787s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s ______ ERROR at teardown of test_read_iris_query[mysql_pymysql_conn_iris] ______ 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s > sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3.13/socket.py:864: in create_connection 2787s raise exceptions[0] 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s address = ('localhost', 3306), timeout = 10, source_address = None 2787s 2787s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2787s source_address=None, *, all_errors=False): 2787s """Connect to *address* and return the socket object. 2787s 2787s Convenience function. Connect to *address* (a 2-tuple ``(host, 2787s port)``) and return the socket object. Passing the optional 2787s *timeout* parameter will set the timeout on the socket instance 2787s before attempting to connect. If no *timeout* is supplied, the 2787s global default timeout setting returned by :func:`getdefaulttimeout` 2787s is used. If *source_address* is set it must be a tuple of (host, port) 2787s for the socket to bind as a source address before making the connection. 2787s A host of '' or port 0 tells the OS to use the default. When a connection 2787s cannot be created, raises the last error if *all_errors* is False, 2787s and an ExceptionGroup of all errors if *all_errors* is True. 2787s """ 2787s 2787s host, port = address 2787s exceptions = [] 2787s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2787s af, socktype, proto, canonname, sa = res 2787s sock = None 2787s try: 2787s sock = socket(af, socktype, proto) 2787s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2787s sock.settimeout(timeout) 2787s if source_address: 2787s sock.bind(source_address) 2787s > sock.connect(sa) 2787s E ConnectionRefusedError: [Errno 111] Connection refused 2787s 2787s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2787s 2787s During handling of the above exception, another exception occurred: 2787s 2787s self = 2787s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2787s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def mysql_pymysql_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s pymysql = td.versioned_importorskip("pymysql") 2787s engine = sqlalchemy.create_engine( 2787s "mysql+pymysql://root@localhost:3306/pandas", 2787s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s __ ERROR at teardown of test_read_iris_query[postgresql_psycopg2_engine_iris] __ 2787s self = 2787s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2787s connection = None, _has_events = None, _allow_revalidate = True 2787s _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def postgresql_psycopg2_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s td.versioned_importorskip("psycopg2") 2787s engine = sqlalchemy.create_engine( 2787s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s E 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s ___ ERROR at teardown of test_read_iris_query[postgresql_psycopg2_conn_iris] ___ 2787s self = 2787s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2787s connection = None, _has_events = None, _allow_revalidate = True 2787s _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def postgresql_psycopg2_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s td.versioned_importorskip("psycopg2") 2787s engine = sqlalchemy.create_engine( 2787s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s E 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s _ ERROR at teardown of test_read_iris_query_chunksize[mysql_pymysql_engine_iris] _ 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s > sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3.13/socket.py:864: in create_connection 2787s raise exceptions[0] 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s address = ('localhost', 3306), timeout = 10, source_address = None 2787s 2787s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2787s source_address=None, *, all_errors=False): 2787s """Connect to *address* and return the socket object. 2787s 2787s Convenience function. Connect to *address* (a 2-tuple ``(host, 2787s port)``) and return the socket object. Passing the optional 2787s *timeout* parameter will set the timeout on the socket instance 2787s before attempting to connect. If no *timeout* is supplied, the 2787s global default timeout setting returned by :func:`getdefaulttimeout` 2787s is used. If *source_address* is set it must be a tuple of (host, port) 2787s for the socket to bind as a source address before making the connection. 2787s A host of '' or port 0 tells the OS to use the default. When a connection 2787s cannot be created, raises the last error if *all_errors* is False, 2787s and an ExceptionGroup of all errors if *all_errors* is True. 2787s """ 2787s 2787s host, port = address 2787s exceptions = [] 2787s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2787s af, socktype, proto, canonname, sa = res 2787s sock = None 2787s try: 2787s sock = socket(af, socktype, proto) 2787s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2787s sock.settimeout(timeout) 2787s if source_address: 2787s sock.bind(source_address) 2787s > sock.connect(sa) 2787s E ConnectionRefusedError: [Errno 111] Connection refused 2787s 2787s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2787s 2787s During handling of the above exception, another exception occurred: 2787s 2787s self = 2787s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2787s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def mysql_pymysql_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s pymysql = td.versioned_importorskip("pymysql") 2787s engine = sqlalchemy.create_engine( 2787s "mysql+pymysql://root@localhost:3306/pandas", 2787s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s _ ERROR at teardown of test_read_iris_query_chunksize[mysql_pymysql_conn_iris] _ 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s > sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3.13/socket.py:864: in create_connection 2787s raise exceptions[0] 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s address = ('localhost', 3306), timeout = 10, source_address = None 2787s 2787s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2787s source_address=None, *, all_errors=False): 2787s """Connect to *address* and return the socket object. 2787s 2787s Convenience function. Connect to *address* (a 2-tuple ``(host, 2787s port)``) and return the socket object. Passing the optional 2787s *timeout* parameter will set the timeout on the socket instance 2787s before attempting to connect. If no *timeout* is supplied, the 2787s global default timeout setting returned by :func:`getdefaulttimeout` 2787s is used. If *source_address* is set it must be a tuple of (host, port) 2787s for the socket to bind as a source address before making the connection. 2787s A host of '' or port 0 tells the OS to use the default. When a connection 2787s cannot be created, raises the last error if *all_errors* is False, 2787s and an ExceptionGroup of all errors if *all_errors* is True. 2787s """ 2787s 2787s host, port = address 2787s exceptions = [] 2787s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2787s af, socktype, proto, canonname, sa = res 2787s sock = None 2787s try: 2787s sock = socket(af, socktype, proto) 2787s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2787s sock.settimeout(timeout) 2787s if source_address: 2787s sock.bind(source_address) 2787s > sock.connect(sa) 2787s E ConnectionRefusedError: [Errno 111] Connection refused 2787s 2787s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2787s 2787s During handling of the above exception, another exception occurred: 2787s 2787s self = 2787s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2787s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def mysql_pymysql_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s pymysql = td.versioned_importorskip("pymysql") 2787s engine = sqlalchemy.create_engine( 2787s "mysql+pymysql://root@localhost:3306/pandas", 2787s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s _ ERROR at teardown of test_read_iris_query_chunksize[postgresql_psycopg2_engine_iris] _ 2787s self = 2787s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2787s connection = None, _has_events = None, _allow_revalidate = True 2787s _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def postgresql_psycopg2_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s td.versioned_importorskip("psycopg2") 2787s engine = sqlalchemy.create_engine( 2787s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s E 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s _ ERROR at teardown of test_read_iris_query_chunksize[postgresql_psycopg2_conn_iris] _ 2787s self = 2787s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2787s connection = None, _has_events = None, _allow_revalidate = True 2787s _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def postgresql_psycopg2_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s td.versioned_importorskip("psycopg2") 2787s engine = sqlalchemy.create_engine( 2787s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s E 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s _ ERROR at teardown of test_read_iris_query_expression_with_parameter[mysql_pymysql_engine_iris] _ 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s > sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3.13/socket.py:864: in create_connection 2787s raise exceptions[0] 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s address = ('localhost', 3306), timeout = 10, source_address = None 2787s 2787s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2787s source_address=None, *, all_errors=False): 2787s """Connect to *address* and return the socket object. 2787s 2787s Convenience function. Connect to *address* (a 2-tuple ``(host, 2787s port)``) and return the socket object. Passing the optional 2787s *timeout* parameter will set the timeout on the socket instance 2787s before attempting to connect. If no *timeout* is supplied, the 2787s global default timeout setting returned by :func:`getdefaulttimeout` 2787s is used. If *source_address* is set it must be a tuple of (host, port) 2787s for the socket to bind as a source address before making the connection. 2787s A host of '' or port 0 tells the OS to use the default. When a connection 2787s cannot be created, raises the last error if *all_errors* is False, 2787s and an ExceptionGroup of all errors if *all_errors* is True. 2787s """ 2787s 2787s host, port = address 2787s exceptions = [] 2787s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2787s af, socktype, proto, canonname, sa = res 2787s sock = None 2787s try: 2787s sock = socket(af, socktype, proto) 2787s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2787s sock.settimeout(timeout) 2787s if source_address: 2787s sock.bind(source_address) 2787s > sock.connect(sa) 2787s E ConnectionRefusedError: [Errno 111] Connection refused 2787s 2787s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2787s 2787s During handling of the above exception, another exception occurred: 2787s 2787s self = 2787s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2787s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def mysql_pymysql_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s pymysql = td.versioned_importorskip("pymysql") 2787s engine = sqlalchemy.create_engine( 2787s "mysql+pymysql://root@localhost:3306/pandas", 2787s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s _ ERROR at teardown of test_read_iris_query_expression_with_parameter[mysql_pymysql_conn_iris] _ 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s > sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3.13/socket.py:864: in create_connection 2787s raise exceptions[0] 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s address = ('localhost', 3306), timeout = 10, source_address = None 2787s 2787s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2787s source_address=None, *, all_errors=False): 2787s """Connect to *address* and return the socket object. 2787s 2787s Convenience function. Connect to *address* (a 2-tuple ``(host, 2787s port)``) and return the socket object. Passing the optional 2787s *timeout* parameter will set the timeout on the socket instance 2787s before attempting to connect. If no *timeout* is supplied, the 2787s global default timeout setting returned by :func:`getdefaulttimeout` 2787s is used. If *source_address* is set it must be a tuple of (host, port) 2787s for the socket to bind as a source address before making the connection. 2787s A host of '' or port 0 tells the OS to use the default. When a connection 2787s cannot be created, raises the last error if *all_errors* is False, 2787s and an ExceptionGroup of all errors if *all_errors* is True. 2787s """ 2787s 2787s host, port = address 2787s exceptions = [] 2787s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2787s af, socktype, proto, canonname, sa = res 2787s sock = None 2787s try: 2787s sock = socket(af, socktype, proto) 2787s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2787s sock.settimeout(timeout) 2787s if source_address: 2787s sock.bind(source_address) 2787s > sock.connect(sa) 2787s E ConnectionRefusedError: [Errno 111] Connection refused 2787s 2787s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2787s 2787s During handling of the above exception, another exception occurred: 2787s 2787s self = 2787s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2787s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def mysql_pymysql_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s pymysql = td.versioned_importorskip("pymysql") 2787s engine = sqlalchemy.create_engine( 2787s "mysql+pymysql://root@localhost:3306/pandas", 2787s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s _ ERROR at teardown of test_read_iris_query_expression_with_parameter[postgresql_psycopg2_engine_iris] _ 2787s self = 2787s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2787s connection = None, _has_events = None, _allow_revalidate = True 2787s _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def postgresql_psycopg2_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s td.versioned_importorskip("psycopg2") 2787s engine = sqlalchemy.create_engine( 2787s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s E 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s _ ERROR at teardown of test_read_iris_query_expression_with_parameter[postgresql_psycopg2_conn_iris] _ 2787s self = 2787s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2787s connection = None, _has_events = None, _allow_revalidate = True 2787s _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def postgresql_psycopg2_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s td.versioned_importorskip("psycopg2") 2787s engine = sqlalchemy.create_engine( 2787s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s E 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s _ ERROR at teardown of test_read_iris_query_string_with_parameter[mysql_pymysql_engine_iris] _ 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s > sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3.13/socket.py:864: in create_connection 2787s raise exceptions[0] 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s address = ('localhost', 3306), timeout = 10, source_address = None 2787s 2787s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2787s source_address=None, *, all_errors=False): 2787s """Connect to *address* and return the socket object. 2787s 2787s Convenience function. Connect to *address* (a 2-tuple ``(host, 2787s port)``) and return the socket object. Passing the optional 2787s *timeout* parameter will set the timeout on the socket instance 2787s before attempting to connect. If no *timeout* is supplied, the 2787s global default timeout setting returned by :func:`getdefaulttimeout` 2787s is used. If *source_address* is set it must be a tuple of (host, port) 2787s for the socket to bind as a source address before making the connection. 2787s A host of '' or port 0 tells the OS to use the default. When a connection 2787s cannot be created, raises the last error if *all_errors* is False, 2787s and an ExceptionGroup of all errors if *all_errors* is True. 2787s """ 2787s 2787s host, port = address 2787s exceptions = [] 2787s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2787s af, socktype, proto, canonname, sa = res 2787s sock = None 2787s try: 2787s sock = socket(af, socktype, proto) 2787s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2787s sock.settimeout(timeout) 2787s if source_address: 2787s sock.bind(source_address) 2787s > sock.connect(sa) 2787s E ConnectionRefusedError: [Errno 111] Connection refused 2787s 2787s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2787s 2787s During handling of the above exception, another exception occurred: 2787s 2787s self = 2787s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2787s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def mysql_pymysql_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s pymysql = td.versioned_importorskip("pymysql") 2787s engine = sqlalchemy.create_engine( 2787s "mysql+pymysql://root@localhost:3306/pandas", 2787s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s _ ERROR at teardown of test_read_iris_query_string_with_parameter[mysql_pymysql_conn_iris] _ 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s > sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3.13/socket.py:864: in create_connection 2787s raise exceptions[0] 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s address = ('localhost', 3306), timeout = 10, source_address = None 2787s 2787s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2787s source_address=None, *, all_errors=False): 2787s """Connect to *address* and return the socket object. 2787s 2787s Convenience function. Connect to *address* (a 2-tuple ``(host, 2787s port)``) and return the socket object. Passing the optional 2787s *timeout* parameter will set the timeout on the socket instance 2787s before attempting to connect. If no *timeout* is supplied, the 2787s global default timeout setting returned by :func:`getdefaulttimeout` 2787s is used. If *source_address* is set it must be a tuple of (host, port) 2787s for the socket to bind as a source address before making the connection. 2787s A host of '' or port 0 tells the OS to use the default. When a connection 2787s cannot be created, raises the last error if *all_errors* is False, 2787s and an ExceptionGroup of all errors if *all_errors* is True. 2787s """ 2787s 2787s host, port = address 2787s exceptions = [] 2787s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2787s af, socktype, proto, canonname, sa = res 2787s sock = None 2787s try: 2787s sock = socket(af, socktype, proto) 2787s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2787s sock.settimeout(timeout) 2787s if source_address: 2787s sock.bind(source_address) 2787s > sock.connect(sa) 2787s E ConnectionRefusedError: [Errno 111] Connection refused 2787s 2787s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2787s 2787s During handling of the above exception, another exception occurred: 2787s 2787s self = 2787s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2787s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def mysql_pymysql_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s pymysql = td.versioned_importorskip("pymysql") 2787s engine = sqlalchemy.create_engine( 2787s "mysql+pymysql://root@localhost:3306/pandas", 2787s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s _ ERROR at teardown of test_read_iris_query_string_with_parameter[postgresql_psycopg2_engine_iris] _ 2787s self = 2787s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2787s connection = None, _has_events = None, _allow_revalidate = True 2787s _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def postgresql_psycopg2_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s td.versioned_importorskip("psycopg2") 2787s engine = sqlalchemy.create_engine( 2787s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s E 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s _ ERROR at teardown of test_read_iris_query_string_with_parameter[postgresql_psycopg2_conn_iris] _ 2787s self = 2787s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2787s connection = None, _has_events = None, _allow_revalidate = True 2787s _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def postgresql_psycopg2_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s td.versioned_importorskip("psycopg2") 2787s engine = sqlalchemy.create_engine( 2787s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s E 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s _____ ERROR at teardown of test_read_iris_table[mysql_pymysql_engine_iris] _____ 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s > sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3.13/socket.py:864: in create_connection 2787s raise exceptions[0] 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s address = ('localhost', 3306), timeout = 10, source_address = None 2787s 2787s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2787s source_address=None, *, all_errors=False): 2787s """Connect to *address* and return the socket object. 2787s 2787s Convenience function. Connect to *address* (a 2-tuple ``(host, 2787s port)``) and return the socket object. Passing the optional 2787s *timeout* parameter will set the timeout on the socket instance 2787s before attempting to connect. If no *timeout* is supplied, the 2787s global default timeout setting returned by :func:`getdefaulttimeout` 2787s is used. If *source_address* is set it must be a tuple of (host, port) 2787s for the socket to bind as a source address before making the connection. 2787s A host of '' or port 0 tells the OS to use the default. When a connection 2787s cannot be created, raises the last error if *all_errors* is False, 2787s and an ExceptionGroup of all errors if *all_errors* is True. 2787s """ 2787s 2787s host, port = address 2787s exceptions = [] 2787s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2787s af, socktype, proto, canonname, sa = res 2787s sock = None 2787s try: 2787s sock = socket(af, socktype, proto) 2787s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2787s sock.settimeout(timeout) 2787s if source_address: 2787s sock.bind(source_address) 2787s > sock.connect(sa) 2787s E ConnectionRefusedError: [Errno 111] Connection refused 2787s 2787s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2787s 2787s During handling of the above exception, another exception occurred: 2787s 2787s self = 2787s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2787s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def mysql_pymysql_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s pymysql = td.versioned_importorskip("pymysql") 2787s engine = sqlalchemy.create_engine( 2787s "mysql+pymysql://root@localhost:3306/pandas", 2787s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s ______ ERROR at teardown of test_read_iris_table[mysql_pymysql_conn_iris] ______ 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s > sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3.13/socket.py:864: in create_connection 2787s raise exceptions[0] 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s address = ('localhost', 3306), timeout = 10, source_address = None 2787s 2787s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2787s source_address=None, *, all_errors=False): 2787s """Connect to *address* and return the socket object. 2787s 2787s Convenience function. Connect to *address* (a 2-tuple ``(host, 2787s port)``) and return the socket object. Passing the optional 2787s *timeout* parameter will set the timeout on the socket instance 2787s before attempting to connect. If no *timeout* is supplied, the 2787s global default timeout setting returned by :func:`getdefaulttimeout` 2787s is used. If *source_address* is set it must be a tuple of (host, port) 2787s for the socket to bind as a source address before making the connection. 2787s A host of '' or port 0 tells the OS to use the default. When a connection 2787s cannot be created, raises the last error if *all_errors* is False, 2787s and an ExceptionGroup of all errors if *all_errors* is True. 2787s """ 2787s 2787s host, port = address 2787s exceptions = [] 2787s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2787s af, socktype, proto, canonname, sa = res 2787s sock = None 2787s try: 2787s sock = socket(af, socktype, proto) 2787s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2787s sock.settimeout(timeout) 2787s if source_address: 2787s sock.bind(source_address) 2787s > sock.connect(sa) 2787s E ConnectionRefusedError: [Errno 111] Connection refused 2787s 2787s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2787s 2787s During handling of the above exception, another exception occurred: 2787s 2787s self = 2787s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2787s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def mysql_pymysql_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s pymysql = td.versioned_importorskip("pymysql") 2787s engine = sqlalchemy.create_engine( 2787s "mysql+pymysql://root@localhost:3306/pandas", 2787s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s __ ERROR at teardown of test_read_iris_table[postgresql_psycopg2_engine_iris] __ 2787s self = 2787s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2787s connection = None, _has_events = None, _allow_revalidate = True 2787s _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def postgresql_psycopg2_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s td.versioned_importorskip("psycopg2") 2787s engine = sqlalchemy.create_engine( 2787s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s E 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s ___ ERROR at teardown of test_read_iris_table[postgresql_psycopg2_conn_iris] ___ 2787s self = 2787s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2787s connection = None, _has_events = None, _allow_revalidate = True 2787s _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def postgresql_psycopg2_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s td.versioned_importorskip("psycopg2") 2787s engine = sqlalchemy.create_engine( 2787s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s E 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s _ ERROR at teardown of test_read_iris_table_chunksize[mysql_pymysql_engine_iris] _ 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s > sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3.13/socket.py:864: in create_connection 2787s raise exceptions[0] 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s address = ('localhost', 3306), timeout = 10, source_address = None 2787s 2787s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2787s source_address=None, *, all_errors=False): 2787s """Connect to *address* and return the socket object. 2787s 2787s Convenience function. Connect to *address* (a 2-tuple ``(host, 2787s port)``) and return the socket object. Passing the optional 2787s *timeout* parameter will set the timeout on the socket instance 2787s before attempting to connect. If no *timeout* is supplied, the 2787s global default timeout setting returned by :func:`getdefaulttimeout` 2787s is used. If *source_address* is set it must be a tuple of (host, port) 2787s for the socket to bind as a source address before making the connection. 2787s A host of '' or port 0 tells the OS to use the default. When a connection 2787s cannot be created, raises the last error if *all_errors* is False, 2787s and an ExceptionGroup of all errors if *all_errors* is True. 2787s """ 2787s 2787s host, port = address 2787s exceptions = [] 2787s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2787s af, socktype, proto, canonname, sa = res 2787s sock = None 2787s try: 2787s sock = socket(af, socktype, proto) 2787s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2787s sock.settimeout(timeout) 2787s if source_address: 2787s sock.bind(source_address) 2787s > sock.connect(sa) 2787s E ConnectionRefusedError: [Errno 111] Connection refused 2787s 2787s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2787s 2787s During handling of the above exception, another exception occurred: 2787s 2787s self = 2787s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2787s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def mysql_pymysql_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s pymysql = td.versioned_importorskip("pymysql") 2787s engine = sqlalchemy.create_engine( 2787s "mysql+pymysql://root@localhost:3306/pandas", 2787s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s _ ERROR at teardown of test_read_iris_table_chunksize[mysql_pymysql_conn_iris] _ 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s > sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3.13/socket.py:864: in create_connection 2787s raise exceptions[0] 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s address = ('localhost', 3306), timeout = 10, source_address = None 2787s 2787s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2787s source_address=None, *, all_errors=False): 2787s """Connect to *address* and return the socket object. 2787s 2787s Convenience function. Connect to *address* (a 2-tuple ``(host, 2787s port)``) and return the socket object. Passing the optional 2787s *timeout* parameter will set the timeout on the socket instance 2787s before attempting to connect. If no *timeout* is supplied, the 2787s global default timeout setting returned by :func:`getdefaulttimeout` 2787s is used. If *source_address* is set it must be a tuple of (host, port) 2787s for the socket to bind as a source address before making the connection. 2787s A host of '' or port 0 tells the OS to use the default. When a connection 2787s cannot be created, raises the last error if *all_errors* is False, 2787s and an ExceptionGroup of all errors if *all_errors* is True. 2787s """ 2787s 2787s host, port = address 2787s exceptions = [] 2787s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2787s af, socktype, proto, canonname, sa = res 2787s sock = None 2787s try: 2787s sock = socket(af, socktype, proto) 2787s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2787s sock.settimeout(timeout) 2787s if source_address: 2787s sock.bind(source_address) 2787s > sock.connect(sa) 2787s E ConnectionRefusedError: [Errno 111] Connection refused 2787s 2787s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2787s 2787s During handling of the above exception, another exception occurred: 2787s 2787s self = 2787s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2787s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def mysql_pymysql_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s pymysql = td.versioned_importorskip("pymysql") 2787s engine = sqlalchemy.create_engine( 2787s "mysql+pymysql://root@localhost:3306/pandas", 2787s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s _ ERROR at teardown of test_read_iris_table_chunksize[postgresql_psycopg2_engine_iris] _ 2787s self = 2787s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2787s connection = None, _has_events = None, _allow_revalidate = True 2787s _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def postgresql_psycopg2_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s td.versioned_importorskip("psycopg2") 2787s engine = sqlalchemy.create_engine( 2787s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s E 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s _ ERROR at teardown of test_read_iris_table_chunksize[postgresql_psycopg2_conn_iris] _ 2787s self = 2787s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2787s connection = None, _has_events = None, _allow_revalidate = True 2787s _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def postgresql_psycopg2_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s td.versioned_importorskip("psycopg2") 2787s engine = sqlalchemy.create_engine( 2787s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s E 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s _______ ERROR at teardown of test_to_sql_callable[mysql_pymysql_engine] ________ 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s > sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3.13/socket.py:864: in create_connection 2787s raise exceptions[0] 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s address = ('localhost', 3306), timeout = 10, source_address = None 2787s 2787s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2787s source_address=None, *, all_errors=False): 2787s """Connect to *address* and return the socket object. 2787s 2787s Convenience function. Connect to *address* (a 2-tuple ``(host, 2787s port)``) and return the socket object. Passing the optional 2787s *timeout* parameter will set the timeout on the socket instance 2787s before attempting to connect. If no *timeout* is supplied, the 2787s global default timeout setting returned by :func:`getdefaulttimeout` 2787s is used. If *source_address* is set it must be a tuple of (host, port) 2787s for the socket to bind as a source address before making the connection. 2787s A host of '' or port 0 tells the OS to use the default. When a connection 2787s cannot be created, raises the last error if *all_errors* is False, 2787s and an ExceptionGroup of all errors if *all_errors* is True. 2787s """ 2787s 2787s host, port = address 2787s exceptions = [] 2787s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2787s af, socktype, proto, canonname, sa = res 2787s sock = None 2787s try: 2787s sock = socket(af, socktype, proto) 2787s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2787s sock.settimeout(timeout) 2787s if source_address: 2787s sock.bind(source_address) 2787s > sock.connect(sa) 2787s E ConnectionRefusedError: [Errno 111] Connection refused 2787s 2787s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2787s 2787s During handling of the above exception, another exception occurred: 2787s 2787s self = 2787s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2787s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def mysql_pymysql_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s pymysql = td.versioned_importorskip("pymysql") 2787s engine = sqlalchemy.create_engine( 2787s "mysql+pymysql://root@localhost:3306/pandas", 2787s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s ________ ERROR at teardown of test_to_sql_callable[mysql_pymysql_conn] _________ 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s > sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3.13/socket.py:864: in create_connection 2787s raise exceptions[0] 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s address = ('localhost', 3306), timeout = 10, source_address = None 2787s 2787s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2787s source_address=None, *, all_errors=False): 2787s """Connect to *address* and return the socket object. 2787s 2787s Convenience function. Connect to *address* (a 2-tuple ``(host, 2787s port)``) and return the socket object. Passing the optional 2787s *timeout* parameter will set the timeout on the socket instance 2787s before attempting to connect. If no *timeout* is supplied, the 2787s global default timeout setting returned by :func:`getdefaulttimeout` 2787s is used. If *source_address* is set it must be a tuple of (host, port) 2787s for the socket to bind as a source address before making the connection. 2787s A host of '' or port 0 tells the OS to use the default. When a connection 2787s cannot be created, raises the last error if *all_errors* is False, 2787s and an ExceptionGroup of all errors if *all_errors* is True. 2787s """ 2787s 2787s host, port = address 2787s exceptions = [] 2787s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2787s af, socktype, proto, canonname, sa = res 2787s sock = None 2787s try: 2787s sock = socket(af, socktype, proto) 2787s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2787s sock.settimeout(timeout) 2787s if source_address: 2787s sock.bind(source_address) 2787s > sock.connect(sa) 2787s E ConnectionRefusedError: [Errno 111] Connection refused 2787s 2787s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2787s 2787s During handling of the above exception, another exception occurred: 2787s 2787s self = 2787s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2787s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def mysql_pymysql_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s pymysql = td.versioned_importorskip("pymysql") 2787s engine = sqlalchemy.create_engine( 2787s "mysql+pymysql://root@localhost:3306/pandas", 2787s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s ____ ERROR at teardown of test_to_sql_callable[postgresql_psycopg2_engine] _____ 2787s self = 2787s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2787s connection = None, _has_events = None, _allow_revalidate = True 2787s _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def postgresql_psycopg2_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s td.versioned_importorskip("psycopg2") 2787s engine = sqlalchemy.create_engine( 2787s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s E 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s _____ ERROR at teardown of test_to_sql_callable[postgresql_psycopg2_conn] ______ 2787s self = 2787s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2787s connection = None, _has_events = None, _allow_revalidate = True 2787s _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def postgresql_psycopg2_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s td.versioned_importorskip("psycopg2") 2787s engine = sqlalchemy.create_engine( 2787s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s E 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s _ ERROR at teardown of test_default_type_conversion[mysql_pymysql_engine_types] _ 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s > sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3.13/socket.py:864: in create_connection 2787s raise exceptions[0] 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s address = ('localhost', 3306), timeout = 10, source_address = None 2787s 2787s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2787s source_address=None, *, all_errors=False): 2787s """Connect to *address* and return the socket object. 2787s 2787s Convenience function. Connect to *address* (a 2-tuple ``(host, 2787s port)``) and return the socket object. Passing the optional 2787s *timeout* parameter will set the timeout on the socket instance 2787s before attempting to connect. If no *timeout* is supplied, the 2787s global default timeout setting returned by :func:`getdefaulttimeout` 2787s is used. If *source_address* is set it must be a tuple of (host, port) 2787s for the socket to bind as a source address before making the connection. 2787s A host of '' or port 0 tells the OS to use the default. When a connection 2787s cannot be created, raises the last error if *all_errors* is False, 2787s and an ExceptionGroup of all errors if *all_errors* is True. 2787s """ 2787s 2787s host, port = address 2787s exceptions = [] 2787s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2787s af, socktype, proto, canonname, sa = res 2787s sock = None 2787s try: 2787s sock = socket(af, socktype, proto) 2787s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2787s sock.settimeout(timeout) 2787s if source_address: 2787s sock.bind(source_address) 2787s > sock.connect(sa) 2787s E ConnectionRefusedError: [Errno 111] Connection refused 2787s 2787s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2787s 2787s During handling of the above exception, another exception occurred: 2787s 2787s self = 2787s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2787s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def mysql_pymysql_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s pymysql = td.versioned_importorskip("pymysql") 2787s engine = sqlalchemy.create_engine( 2787s "mysql+pymysql://root@localhost:3306/pandas", 2787s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s _ ERROR at teardown of test_default_type_conversion[mysql_pymysql_conn_types] __ 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s > sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3.13/socket.py:864: in create_connection 2787s raise exceptions[0] 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s address = ('localhost', 3306), timeout = 10, source_address = None 2787s 2787s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2787s source_address=None, *, all_errors=False): 2787s """Connect to *address* and return the socket object. 2787s 2787s Convenience function. Connect to *address* (a 2-tuple ``(host, 2787s port)``) and return the socket object. Passing the optional 2787s *timeout* parameter will set the timeout on the socket instance 2787s before attempting to connect. If no *timeout* is supplied, the 2787s global default timeout setting returned by :func:`getdefaulttimeout` 2787s is used. If *source_address* is set it must be a tuple of (host, port) 2787s for the socket to bind as a source address before making the connection. 2787s A host of '' or port 0 tells the OS to use the default. When a connection 2787s cannot be created, raises the last error if *all_errors* is False, 2787s and an ExceptionGroup of all errors if *all_errors* is True. 2787s """ 2787s 2787s host, port = address 2787s exceptions = [] 2787s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2787s af, socktype, proto, canonname, sa = res 2787s sock = None 2787s try: 2787s sock = socket(af, socktype, proto) 2787s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2787s sock.settimeout(timeout) 2787s if source_address: 2787s sock.bind(source_address) 2787s > sock.connect(sa) 2787s E ConnectionRefusedError: [Errno 111] Connection refused 2787s 2787s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2787s 2787s During handling of the above exception, another exception occurred: 2787s 2787s self = 2787s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2787s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def mysql_pymysql_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s pymysql = td.versioned_importorskip("pymysql") 2787s engine = sqlalchemy.create_engine( 2787s "mysql+pymysql://root@localhost:3306/pandas", 2787s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s _ ERROR at teardown of test_default_type_conversion[postgresql_psycopg2_engine_types] _ 2787s self = 2787s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2787s connection = None, _has_events = None, _allow_revalidate = True 2787s _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def postgresql_psycopg2_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s td.versioned_importorskip("psycopg2") 2787s engine = sqlalchemy.create_engine( 2787s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s E 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s _ ERROR at teardown of test_default_type_conversion[postgresql_psycopg2_conn_types] _ 2787s self = 2787s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2787s connection = None, _has_events = None, _allow_revalidate = True 2787s _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def postgresql_psycopg2_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s td.versioned_importorskip("psycopg2") 2787s engine = sqlalchemy.create_engine( 2787s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s E 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s ________ ERROR at teardown of test_read_procedure[mysql_pymysql_engine] ________ 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s > sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3.13/socket.py:864: in create_connection 2787s raise exceptions[0] 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s address = ('localhost', 3306), timeout = 10, source_address = None 2787s 2787s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2787s source_address=None, *, all_errors=False): 2787s """Connect to *address* and return the socket object. 2787s 2787s Convenience function. Connect to *address* (a 2-tuple ``(host, 2787s port)``) and return the socket object. Passing the optional 2787s *timeout* parameter will set the timeout on the socket instance 2787s before attempting to connect. If no *timeout* is supplied, the 2787s global default timeout setting returned by :func:`getdefaulttimeout` 2787s is used. If *source_address* is set it must be a tuple of (host, port) 2787s for the socket to bind as a source address before making the connection. 2787s A host of '' or port 0 tells the OS to use the default. When a connection 2787s cannot be created, raises the last error if *all_errors* is False, 2787s and an ExceptionGroup of all errors if *all_errors* is True. 2787s """ 2787s 2787s host, port = address 2787s exceptions = [] 2787s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2787s af, socktype, proto, canonname, sa = res 2787s sock = None 2787s try: 2787s sock = socket(af, socktype, proto) 2787s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2787s sock.settimeout(timeout) 2787s if source_address: 2787s sock.bind(source_address) 2787s > sock.connect(sa) 2787s E ConnectionRefusedError: [Errno 111] Connection refused 2787s 2787s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2787s 2787s During handling of the above exception, another exception occurred: 2787s 2787s self = 2787s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2787s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def mysql_pymysql_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s pymysql = td.versioned_importorskip("pymysql") 2787s engine = sqlalchemy.create_engine( 2787s "mysql+pymysql://root@localhost:3306/pandas", 2787s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s _________ ERROR at teardown of test_read_procedure[mysql_pymysql_conn] _________ 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s > sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3.13/socket.py:864: in create_connection 2787s raise exceptions[0] 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s address = ('localhost', 3306), timeout = 10, source_address = None 2787s 2787s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2787s source_address=None, *, all_errors=False): 2787s """Connect to *address* and return the socket object. 2787s 2787s Convenience function. Connect to *address* (a 2-tuple ``(host, 2787s port)``) and return the socket object. Passing the optional 2787s *timeout* parameter will set the timeout on the socket instance 2787s before attempting to connect. If no *timeout* is supplied, the 2787s global default timeout setting returned by :func:`getdefaulttimeout` 2787s is used. If *source_address* is set it must be a tuple of (host, port) 2787s for the socket to bind as a source address before making the connection. 2787s A host of '' or port 0 tells the OS to use the default. When a connection 2787s cannot be created, raises the last error if *all_errors* is False, 2787s and an ExceptionGroup of all errors if *all_errors* is True. 2787s """ 2787s 2787s host, port = address 2787s exceptions = [] 2787s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2787s af, socktype, proto, canonname, sa = res 2787s sock = None 2787s try: 2787s sock = socket(af, socktype, proto) 2787s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2787s sock.settimeout(timeout) 2787s if source_address: 2787s sock.bind(source_address) 2787s > sock.connect(sa) 2787s E ConnectionRefusedError: [Errno 111] Connection refused 2787s 2787s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2787s 2787s During handling of the above exception, another exception occurred: 2787s 2787s self = 2787s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2787s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def mysql_pymysql_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s pymysql = td.versioned_importorskip("pymysql") 2787s engine = sqlalchemy.create_engine( 2787s "mysql+pymysql://root@localhost:3306/pandas", 2787s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s _ ERROR at teardown of test_copy_from_callable_insertion_method[2-postgresql_psycopg2_engine] _ 2787s self = 2787s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2787s connection = None, _has_events = None, _allow_revalidate = True 2787s _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def postgresql_psycopg2_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s td.versioned_importorskip("psycopg2") 2787s engine = sqlalchemy.create_engine( 2787s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s E 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s _ ERROR at teardown of test_copy_from_callable_insertion_method[2-postgresql_psycopg2_conn] _ 2787s self = 2787s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2787s connection = None, _has_events = None, _allow_revalidate = True 2787s _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def postgresql_psycopg2_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s td.versioned_importorskip("psycopg2") 2787s engine = sqlalchemy.create_engine( 2787s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s E 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s _ ERROR at teardown of test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_engine] _ 2787s self = 2787s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2787s connection = None, _has_events = None, _allow_revalidate = True 2787s _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def postgresql_psycopg2_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s td.versioned_importorskip("psycopg2") 2787s engine = sqlalchemy.create_engine( 2787s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s E 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s _ ERROR at teardown of test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_conn] _ 2787s self = 2787s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2787s connection = None, _has_events = None, _allow_revalidate = True 2787s _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def postgresql_psycopg2_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s td.versioned_importorskip("psycopg2") 2787s engine = sqlalchemy.create_engine( 2787s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s E 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s _ ERROR at teardown of test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_engine] _ 2787s self = 2787s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2787s connection = None, _has_events = None, _allow_revalidate = True 2787s _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def postgresql_psycopg2_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s td.versioned_importorskip("psycopg2") 2787s engine = sqlalchemy.create_engine( 2787s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s E 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s _ ERROR at teardown of test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_conn] _ 2787s self = 2787s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2787s connection = None, _has_events = None, _allow_revalidate = True 2787s _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def postgresql_psycopg2_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s td.versioned_importorskip("psycopg2") 2787s engine = sqlalchemy.create_engine( 2787s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s E 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s _ ERROR at teardown of test_to_sql_on_public_schema[postgresql_psycopg2_engine] _ 2787s self = 2787s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2787s connection = None, _has_events = None, _allow_revalidate = True 2787s _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def postgresql_psycopg2_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s td.versioned_importorskip("psycopg2") 2787s engine = sqlalchemy.create_engine( 2787s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s E 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s _ ERROR at teardown of test_to_sql_on_public_schema[postgresql_psycopg2_conn] __ 2787s self = 2787s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2787s connection = None, _has_events = None, _allow_revalidate = True 2787s _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def postgresql_psycopg2_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s td.versioned_importorskip("psycopg2") 2787s engine = sqlalchemy.create_engine( 2787s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s E 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s _ ERROR at teardown of test_insertion_method_on_conflict_update[mysql_pymysql_engine] _ 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s > sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3.13/socket.py:864: in create_connection 2787s raise exceptions[0] 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s address = ('localhost', 3306), timeout = 10, source_address = None 2787s 2787s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2787s source_address=None, *, all_errors=False): 2787s """Connect to *address* and return the socket object. 2787s 2787s Convenience function. Connect to *address* (a 2-tuple ``(host, 2787s port)``) and return the socket object. Passing the optional 2787s *timeout* parameter will set the timeout on the socket instance 2787s before attempting to connect. If no *timeout* is supplied, the 2787s global default timeout setting returned by :func:`getdefaulttimeout` 2787s is used. If *source_address* is set it must be a tuple of (host, port) 2787s for the socket to bind as a source address before making the connection. 2787s A host of '' or port 0 tells the OS to use the default. When a connection 2787s cannot be created, raises the last error if *all_errors* is False, 2787s and an ExceptionGroup of all errors if *all_errors* is True. 2787s """ 2787s 2787s host, port = address 2787s exceptions = [] 2787s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2787s af, socktype, proto, canonname, sa = res 2787s sock = None 2787s try: 2787s sock = socket(af, socktype, proto) 2787s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2787s sock.settimeout(timeout) 2787s if source_address: 2787s sock.bind(source_address) 2787s > sock.connect(sa) 2787s E ConnectionRefusedError: [Errno 111] Connection refused 2787s 2787s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2787s 2787s During handling of the above exception, another exception occurred: 2787s 2787s self = 2787s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2787s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def mysql_pymysql_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s pymysql = td.versioned_importorskip("pymysql") 2787s engine = sqlalchemy.create_engine( 2787s "mysql+pymysql://root@localhost:3306/pandas", 2787s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s _ ERROR at teardown of test_insertion_method_on_conflict_update[mysql_pymysql_conn] _ 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s > sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3.13/socket.py:864: in create_connection 2787s raise exceptions[0] 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s address = ('localhost', 3306), timeout = 10, source_address = None 2787s 2787s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2787s source_address=None, *, all_errors=False): 2787s """Connect to *address* and return the socket object. 2787s 2787s Convenience function. Connect to *address* (a 2-tuple ``(host, 2787s port)``) and return the socket object. Passing the optional 2787s *timeout* parameter will set the timeout on the socket instance 2787s before attempting to connect. If no *timeout* is supplied, the 2787s global default timeout setting returned by :func:`getdefaulttimeout` 2787s is used. If *source_address* is set it must be a tuple of (host, port) 2787s for the socket to bind as a source address before making the connection. 2787s A host of '' or port 0 tells the OS to use the default. When a connection 2787s cannot be created, raises the last error if *all_errors* is False, 2787s and an ExceptionGroup of all errors if *all_errors* is True. 2787s """ 2787s 2787s host, port = address 2787s exceptions = [] 2787s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2787s af, socktype, proto, canonname, sa = res 2787s sock = None 2787s try: 2787s sock = socket(af, socktype, proto) 2787s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2787s sock.settimeout(timeout) 2787s if source_address: 2787s sock.bind(source_address) 2787s > sock.connect(sa) 2787s E ConnectionRefusedError: [Errno 111] Connection refused 2787s 2787s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2787s 2787s During handling of the above exception, another exception occurred: 2787s 2787s self = 2787s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2787s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def mysql_pymysql_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s pymysql = td.versioned_importorskip("pymysql") 2787s engine = sqlalchemy.create_engine( 2787s "mysql+pymysql://root@localhost:3306/pandas", 2787s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s ___ ERROR at teardown of test_read_view_postgres[postgresql_psycopg2_engine] ___ 2787s self = 2787s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2787s connection = None, _has_events = None, _allow_revalidate = True 2787s _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def postgresql_psycopg2_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s td.versioned_importorskip("psycopg2") 2787s engine = sqlalchemy.create_engine( 2787s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s E 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s ____ ERROR at teardown of test_read_view_postgres[postgresql_psycopg2_conn] ____ 2787s self = 2787s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2787s connection = None, _has_events = None, _allow_revalidate = True 2787s _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def postgresql_psycopg2_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s td.versioned_importorskip("psycopg2") 2787s engine = sqlalchemy.create_engine( 2787s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s E 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s _ ERROR at teardown of test_read_sql_iris_parameter[mysql_pymysql_engine_iris] _ 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s > sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3.13/socket.py:864: in create_connection 2787s raise exceptions[0] 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s address = ('localhost', 3306), timeout = 10, source_address = None 2787s 2787s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2787s source_address=None, *, all_errors=False): 2787s """Connect to *address* and return the socket object. 2787s 2787s Convenience function. Connect to *address* (a 2-tuple ``(host, 2787s port)``) and return the socket object. Passing the optional 2787s *timeout* parameter will set the timeout on the socket instance 2787s before attempting to connect. If no *timeout* is supplied, the 2787s global default timeout setting returned by :func:`getdefaulttimeout` 2787s is used. If *source_address* is set it must be a tuple of (host, port) 2787s for the socket to bind as a source address before making the connection. 2787s A host of '' or port 0 tells the OS to use the default. When a connection 2787s cannot be created, raises the last error if *all_errors* is False, 2787s and an ExceptionGroup of all errors if *all_errors* is True. 2787s """ 2787s 2787s host, port = address 2787s exceptions = [] 2787s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2787s af, socktype, proto, canonname, sa = res 2787s sock = None 2787s try: 2787s sock = socket(af, socktype, proto) 2787s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2787s sock.settimeout(timeout) 2787s if source_address: 2787s sock.bind(source_address) 2787s > sock.connect(sa) 2787s E ConnectionRefusedError: [Errno 111] Connection refused 2787s 2787s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2787s 2787s During handling of the above exception, another exception occurred: 2787s 2787s self = 2787s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2787s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def mysql_pymysql_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s pymysql = td.versioned_importorskip("pymysql") 2787s engine = sqlalchemy.create_engine( 2787s "mysql+pymysql://root@localhost:3306/pandas", 2787s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s __ ERROR at teardown of test_read_sql_iris_parameter[mysql_pymysql_conn_iris] __ 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s > sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3.13/socket.py:864: in create_connection 2787s raise exceptions[0] 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s address = ('localhost', 3306), timeout = 10, source_address = None 2787s 2787s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2787s source_address=None, *, all_errors=False): 2787s """Connect to *address* and return the socket object. 2787s 2787s Convenience function. Connect to *address* (a 2-tuple ``(host, 2787s port)``) and return the socket object. Passing the optional 2787s *timeout* parameter will set the timeout on the socket instance 2787s before attempting to connect. If no *timeout* is supplied, the 2787s global default timeout setting returned by :func:`getdefaulttimeout` 2787s is used. If *source_address* is set it must be a tuple of (host, port) 2787s for the socket to bind as a source address before making the connection. 2787s A host of '' or port 0 tells the OS to use the default. When a connection 2787s cannot be created, raises the last error if *all_errors* is False, 2787s and an ExceptionGroup of all errors if *all_errors* is True. 2787s """ 2787s 2787s host, port = address 2787s exceptions = [] 2787s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2787s af, socktype, proto, canonname, sa = res 2787s sock = None 2787s try: 2787s sock = socket(af, socktype, proto) 2787s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2787s sock.settimeout(timeout) 2787s if source_address: 2787s sock.bind(source_address) 2787s > sock.connect(sa) 2787s E ConnectionRefusedError: [Errno 111] Connection refused 2787s 2787s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2787s 2787s During handling of the above exception, another exception occurred: 2787s 2787s self = 2787s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2787s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def mysql_pymysql_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s pymysql = td.versioned_importorskip("pymysql") 2787s engine = sqlalchemy.create_engine( 2787s "mysql+pymysql://root@localhost:3306/pandas", 2787s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s _ ERROR at teardown of test_read_sql_iris_parameter[postgresql_psycopg2_engine_iris] _ 2787s self = 2787s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2787s connection = None, _has_events = None, _allow_revalidate = True 2787s _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def postgresql_psycopg2_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s td.versioned_importorskip("psycopg2") 2787s engine = sqlalchemy.create_engine( 2787s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s E 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s _ ERROR at teardown of test_read_sql_iris_parameter[postgresql_psycopg2_conn_iris] _ 2787s self = 2787s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2787s connection = None, _has_events = None, _allow_revalidate = True 2787s _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def postgresql_psycopg2_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s td.versioned_importorskip("psycopg2") 2787s engine = sqlalchemy.create_engine( 2787s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s E 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s _ ERROR at teardown of test_read_sql_iris_named_parameter[mysql_pymysql_engine_iris] _ 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s > sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3.13/socket.py:864: in create_connection 2787s raise exceptions[0] 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s address = ('localhost', 3306), timeout = 10, source_address = None 2787s 2787s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2787s source_address=None, *, all_errors=False): 2787s """Connect to *address* and return the socket object. 2787s 2787s Convenience function. Connect to *address* (a 2-tuple ``(host, 2787s port)``) and return the socket object. Passing the optional 2787s *timeout* parameter will set the timeout on the socket instance 2787s before attempting to connect. If no *timeout* is supplied, the 2787s global default timeout setting returned by :func:`getdefaulttimeout` 2787s is used. If *source_address* is set it must be a tuple of (host, port) 2787s for the socket to bind as a source address before making the connection. 2787s A host of '' or port 0 tells the OS to use the default. When a connection 2787s cannot be created, raises the last error if *all_errors* is False, 2787s and an ExceptionGroup of all errors if *all_errors* is True. 2787s """ 2787s 2787s host, port = address 2787s exceptions = [] 2787s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2787s af, socktype, proto, canonname, sa = res 2787s sock = None 2787s try: 2787s sock = socket(af, socktype, proto) 2787s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2787s sock.settimeout(timeout) 2787s if source_address: 2787s sock.bind(source_address) 2787s > sock.connect(sa) 2787s E ConnectionRefusedError: [Errno 111] Connection refused 2787s 2787s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2787s 2787s During handling of the above exception, another exception occurred: 2787s 2787s self = 2787s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2787s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def mysql_pymysql_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s pymysql = td.versioned_importorskip("pymysql") 2787s engine = sqlalchemy.create_engine( 2787s "mysql+pymysql://root@localhost:3306/pandas", 2787s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s _ ERROR at teardown of test_read_sql_iris_named_parameter[mysql_pymysql_conn_iris] _ 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s > sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3.13/socket.py:864: in create_connection 2787s raise exceptions[0] 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s address = ('localhost', 3306), timeout = 10, source_address = None 2787s 2787s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2787s source_address=None, *, all_errors=False): 2787s """Connect to *address* and return the socket object. 2787s 2787s Convenience function. Connect to *address* (a 2-tuple ``(host, 2787s port)``) and return the socket object. Passing the optional 2787s *timeout* parameter will set the timeout on the socket instance 2787s before attempting to connect. If no *timeout* is supplied, the 2787s global default timeout setting returned by :func:`getdefaulttimeout` 2787s is used. If *source_address* is set it must be a tuple of (host, port) 2787s for the socket to bind as a source address before making the connection. 2787s A host of '' or port 0 tells the OS to use the default. When a connection 2787s cannot be created, raises the last error if *all_errors* is False, 2787s and an ExceptionGroup of all errors if *all_errors* is True. 2787s """ 2787s 2787s host, port = address 2787s exceptions = [] 2787s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2787s af, socktype, proto, canonname, sa = res 2787s sock = None 2787s try: 2787s sock = socket(af, socktype, proto) 2787s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2787s sock.settimeout(timeout) 2787s if source_address: 2787s sock.bind(source_address) 2787s > sock.connect(sa) 2787s E ConnectionRefusedError: [Errno 111] Connection refused 2787s 2787s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2787s 2787s During handling of the above exception, another exception occurred: 2787s 2787s self = 2787s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2787s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def mysql_pymysql_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s pymysql = td.versioned_importorskip("pymysql") 2787s engine = sqlalchemy.create_engine( 2787s "mysql+pymysql://root@localhost:3306/pandas", 2787s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s _ ERROR at teardown of test_read_sql_iris_named_parameter[postgresql_psycopg2_engine_iris] _ 2787s self = 2787s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2787s connection = None, _has_events = None, _allow_revalidate = True 2787s _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def postgresql_psycopg2_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s td.versioned_importorskip("psycopg2") 2787s engine = sqlalchemy.create_engine( 2787s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s E 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s _ ERROR at teardown of test_read_sql_iris_named_parameter[postgresql_psycopg2_conn_iris] _ 2787s self = 2787s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2787s connection = None, _has_events = None, _allow_revalidate = True 2787s _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def postgresql_psycopg2_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s td.versioned_importorskip("psycopg2") 2787s engine = sqlalchemy.create_engine( 2787s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s E 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s ____ ERROR at teardown of test_api_read_sql_view[mysql_pymysql_engine_iris] ____ 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s > sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3.13/socket.py:864: in create_connection 2787s raise exceptions[0] 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s address = ('localhost', 3306), timeout = 10, source_address = None 2787s 2787s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2787s source_address=None, *, all_errors=False): 2787s """Connect to *address* and return the socket object. 2787s 2787s Convenience function. Connect to *address* (a 2-tuple ``(host, 2787s port)``) and return the socket object. Passing the optional 2787s *timeout* parameter will set the timeout on the socket instance 2787s before attempting to connect. If no *timeout* is supplied, the 2787s global default timeout setting returned by :func:`getdefaulttimeout` 2787s is used. If *source_address* is set it must be a tuple of (host, port) 2787s for the socket to bind as a source address before making the connection. 2787s A host of '' or port 0 tells the OS to use the default. When a connection 2787s cannot be created, raises the last error if *all_errors* is False, 2787s and an ExceptionGroup of all errors if *all_errors* is True. 2787s """ 2787s 2787s host, port = address 2787s exceptions = [] 2787s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2787s af, socktype, proto, canonname, sa = res 2787s sock = None 2787s try: 2787s sock = socket(af, socktype, proto) 2787s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2787s sock.settimeout(timeout) 2787s if source_address: 2787s sock.bind(source_address) 2787s > sock.connect(sa) 2787s E ConnectionRefusedError: [Errno 111] Connection refused 2787s 2787s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2787s 2787s During handling of the above exception, another exception occurred: 2787s 2787s self = 2787s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2787s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def mysql_pymysql_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s pymysql = td.versioned_importorskip("pymysql") 2787s engine = sqlalchemy.create_engine( 2787s "mysql+pymysql://root@localhost:3306/pandas", 2787s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s _____ ERROR at teardown of test_api_read_sql_view[mysql_pymysql_conn_iris] _____ 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s > sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3.13/socket.py:864: in create_connection 2787s raise exceptions[0] 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s address = ('localhost', 3306), timeout = 10, source_address = None 2787s 2787s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2787s source_address=None, *, all_errors=False): 2787s """Connect to *address* and return the socket object. 2787s 2787s Convenience function. Connect to *address* (a 2-tuple ``(host, 2787s port)``) and return the socket object. Passing the optional 2787s *timeout* parameter will set the timeout on the socket instance 2787s before attempting to connect. If no *timeout* is supplied, the 2787s global default timeout setting returned by :func:`getdefaulttimeout` 2787s is used. If *source_address* is set it must be a tuple of (host, port) 2787s for the socket to bind as a source address before making the connection. 2787s A host of '' or port 0 tells the OS to use the default. When a connection 2787s cannot be created, raises the last error if *all_errors* is False, 2787s and an ExceptionGroup of all errors if *all_errors* is True. 2787s """ 2787s 2787s host, port = address 2787s exceptions = [] 2787s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2787s af, socktype, proto, canonname, sa = res 2787s sock = None 2787s try: 2787s sock = socket(af, socktype, proto) 2787s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2787s sock.settimeout(timeout) 2787s if source_address: 2787s sock.bind(source_address) 2787s > sock.connect(sa) 2787s E ConnectionRefusedError: [Errno 111] Connection refused 2787s 2787s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2787s 2787s During handling of the above exception, another exception occurred: 2787s 2787s self = 2787s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2787s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def mysql_pymysql_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s pymysql = td.versioned_importorskip("pymysql") 2787s engine = sqlalchemy.create_engine( 2787s "mysql+pymysql://root@localhost:3306/pandas", 2787s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s _ ERROR at teardown of test_api_read_sql_view[postgresql_psycopg2_engine_iris] _ 2787s self = 2787s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2787s connection = None, _has_events = None, _allow_revalidate = True 2787s _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def postgresql_psycopg2_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s td.versioned_importorskip("psycopg2") 2787s engine = sqlalchemy.create_engine( 2787s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s E 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s __ ERROR at teardown of test_api_read_sql_view[postgresql_psycopg2_conn_iris] __ 2787s self = 2787s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2787s connection = None, _has_events = None, _allow_revalidate = True 2787s _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def postgresql_psycopg2_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s td.versioned_importorskip("psycopg2") 2787s engine = sqlalchemy.create_engine( 2787s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s E 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s _ ERROR at teardown of test_api_read_sql_with_chunksize_no_result[mysql_pymysql_engine_iris] _ 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s > sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3.13/socket.py:864: in create_connection 2787s raise exceptions[0] 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s address = ('localhost', 3306), timeout = 10, source_address = None 2787s 2787s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2787s source_address=None, *, all_errors=False): 2787s """Connect to *address* and return the socket object. 2787s 2787s Convenience function. Connect to *address* (a 2-tuple ``(host, 2787s port)``) and return the socket object. Passing the optional 2787s *timeout* parameter will set the timeout on the socket instance 2787s before attempting to connect. If no *timeout* is supplied, the 2787s global default timeout setting returned by :func:`getdefaulttimeout` 2787s is used. If *source_address* is set it must be a tuple of (host, port) 2787s for the socket to bind as a source address before making the connection. 2787s A host of '' or port 0 tells the OS to use the default. When a connection 2787s cannot be created, raises the last error if *all_errors* is False, 2787s and an ExceptionGroup of all errors if *all_errors* is True. 2787s """ 2787s 2787s host, port = address 2787s exceptions = [] 2787s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2787s af, socktype, proto, canonname, sa = res 2787s sock = None 2787s try: 2787s sock = socket(af, socktype, proto) 2787s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2787s sock.settimeout(timeout) 2787s if source_address: 2787s sock.bind(source_address) 2787s > sock.connect(sa) 2787s E ConnectionRefusedError: [Errno 111] Connection refused 2787s 2787s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2787s 2787s During handling of the above exception, another exception occurred: 2787s 2787s self = 2787s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2787s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def mysql_pymysql_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s pymysql = td.versioned_importorskip("pymysql") 2787s engine = sqlalchemy.create_engine( 2787s "mysql+pymysql://root@localhost:3306/pandas", 2787s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s _ ERROR at teardown of test_api_read_sql_with_chunksize_no_result[mysql_pymysql_conn_iris] _ 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s > sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3.13/socket.py:864: in create_connection 2787s raise exceptions[0] 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s address = ('localhost', 3306), timeout = 10, source_address = None 2787s 2787s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2787s source_address=None, *, all_errors=False): 2787s """Connect to *address* and return the socket object. 2787s 2787s Convenience function. Connect to *address* (a 2-tuple ``(host, 2787s port)``) and return the socket object. Passing the optional 2787s *timeout* parameter will set the timeout on the socket instance 2787s before attempting to connect. If no *timeout* is supplied, the 2787s global default timeout setting returned by :func:`getdefaulttimeout` 2787s is used. If *source_address* is set it must be a tuple of (host, port) 2787s for the socket to bind as a source address before making the connection. 2787s A host of '' or port 0 tells the OS to use the default. When a connection 2787s cannot be created, raises the last error if *all_errors* is False, 2787s and an ExceptionGroup of all errors if *all_errors* is True. 2787s """ 2787s 2787s host, port = address 2787s exceptions = [] 2787s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2787s af, socktype, proto, canonname, sa = res 2787s sock = None 2787s try: 2787s sock = socket(af, socktype, proto) 2787s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2787s sock.settimeout(timeout) 2787s if source_address: 2787s sock.bind(source_address) 2787s > sock.connect(sa) 2787s E ConnectionRefusedError: [Errno 111] Connection refused 2787s 2787s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2787s 2787s During handling of the above exception, another exception occurred: 2787s 2787s self = 2787s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2787s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def mysql_pymysql_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s pymysql = td.versioned_importorskip("pymysql") 2787s engine = sqlalchemy.create_engine( 2787s "mysql+pymysql://root@localhost:3306/pandas", 2787s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s _ ERROR at teardown of test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_engine_iris] _ 2787s self = 2787s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2787s connection = None, _has_events = None, _allow_revalidate = True 2787s _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def postgresql_psycopg2_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s td.versioned_importorskip("psycopg2") 2787s engine = sqlalchemy.create_engine( 2787s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s E 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s _ ERROR at teardown of test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_conn_iris] _ 2787s self = 2787s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2787s connection = None, _has_events = None, _allow_revalidate = True 2787s _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def postgresql_psycopg2_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s td.versioned_importorskip("psycopg2") 2787s engine = sqlalchemy.create_engine( 2787s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s E 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s __________ ERROR at teardown of test_api_to_sql[mysql_pymysql_engine] __________ 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s > sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3.13/socket.py:864: in create_connection 2787s raise exceptions[0] 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s address = ('localhost', 3306), timeout = 10, source_address = None 2787s 2787s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2787s source_address=None, *, all_errors=False): 2787s """Connect to *address* and return the socket object. 2787s 2787s Convenience function. Connect to *address* (a 2-tuple ``(host, 2787s port)``) and return the socket object. Passing the optional 2787s *timeout* parameter will set the timeout on the socket instance 2787s before attempting to connect. If no *timeout* is supplied, the 2787s global default timeout setting returned by :func:`getdefaulttimeout` 2787s is used. If *source_address* is set it must be a tuple of (host, port) 2787s for the socket to bind as a source address before making the connection. 2787s A host of '' or port 0 tells the OS to use the default. When a connection 2787s cannot be created, raises the last error if *all_errors* is False, 2787s and an ExceptionGroup of all errors if *all_errors* is True. 2787s """ 2787s 2787s host, port = address 2787s exceptions = [] 2787s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2787s af, socktype, proto, canonname, sa = res 2787s sock = None 2787s try: 2787s sock = socket(af, socktype, proto) 2787s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2787s sock.settimeout(timeout) 2787s if source_address: 2787s sock.bind(source_address) 2787s > sock.connect(sa) 2787s E ConnectionRefusedError: [Errno 111] Connection refused 2787s 2787s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2787s 2787s During handling of the above exception, another exception occurred: 2787s 2787s self = 2787s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2787s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def mysql_pymysql_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s pymysql = td.versioned_importorskip("pymysql") 2787s engine = sqlalchemy.create_engine( 2787s "mysql+pymysql://root@localhost:3306/pandas", 2787s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s ___________ ERROR at teardown of test_api_to_sql[mysql_pymysql_conn] ___________ 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s > sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3.13/socket.py:864: in create_connection 2787s raise exceptions[0] 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s address = ('localhost', 3306), timeout = 10, source_address = None 2787s 2787s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2787s source_address=None, *, all_errors=False): 2787s """Connect to *address* and return the socket object. 2787s 2787s Convenience function. Connect to *address* (a 2-tuple ``(host, 2787s port)``) and return the socket object. Passing the optional 2787s *timeout* parameter will set the timeout on the socket instance 2787s before attempting to connect. If no *timeout* is supplied, the 2787s global default timeout setting returned by :func:`getdefaulttimeout` 2787s is used. If *source_address* is set it must be a tuple of (host, port) 2787s for the socket to bind as a source address before making the connection. 2787s A host of '' or port 0 tells the OS to use the default. When a connection 2787s cannot be created, raises the last error if *all_errors* is False, 2787s and an ExceptionGroup of all errors if *all_errors* is True. 2787s """ 2787s 2787s host, port = address 2787s exceptions = [] 2787s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2787s af, socktype, proto, canonname, sa = res 2787s sock = None 2787s try: 2787s sock = socket(af, socktype, proto) 2787s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2787s sock.settimeout(timeout) 2787s if source_address: 2787s sock.bind(source_address) 2787s > sock.connect(sa) 2787s E ConnectionRefusedError: [Errno 111] Connection refused 2787s 2787s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2787s 2787s During handling of the above exception, another exception occurred: 2787s 2787s self = 2787s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2787s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def mysql_pymysql_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s pymysql = td.versioned_importorskip("pymysql") 2787s engine = sqlalchemy.create_engine( 2787s "mysql+pymysql://root@localhost:3306/pandas", 2787s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2787s self.connect() 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s self = , sock = None 2787s 2787s def connect(self, sock=None): 2787s self._closed = False 2787s try: 2787s if sock is None: 2787s if self.unix_socket: 2787s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2787s sock.settimeout(self.connect_timeout) 2787s sock.connect(self.unix_socket) 2787s self.host_info = "Localhost via UNIX socket" 2787s self._secure = True 2787s if DEBUG: 2787s print("connected using unix_socket") 2787s else: 2787s kwargs = {} 2787s if self.bind_address is not None: 2787s kwargs["source_address"] = (self.bind_address, 0) 2787s while True: 2787s try: 2787s sock = socket.create_connection( 2787s (self.host, self.port), self.connect_timeout, **kwargs 2787s ) 2787s break 2787s except OSError as e: 2787s if e.errno == errno.EINTR: 2787s continue 2787s raise 2787s self.host_info = "socket %s:%d" % (self.host, self.port) 2787s if DEBUG: 2787s print("connected using socket") 2787s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2787s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2787s sock.settimeout(None) 2787s 2787s self._sock = sock 2787s self._rfile = sock.makefile("rb") 2787s self._next_seq_id = 0 2787s 2787s self._get_server_information() 2787s self._request_authentication() 2787s 2787s # Send "SET NAMES" query on init for: 2787s # - Ensure charaset (and collation) is set to the server. 2787s # - collation_id in handshake packet may be ignored. 2787s # - If collation is not specified, we don't know what is server's 2787s # default collation for the charset. For example, default collation 2787s # of utf8mb4 is: 2787s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2787s # - MySQL 8.0: utf8mb4_0900_ai_ci 2787s # 2787s # Reference: 2787s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2787s # - https://github.com/wagtail/wagtail/issues/9477 2787s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2787s self.set_character_set(self.charset, self.collation) 2787s 2787s if self.sql_mode is not None: 2787s c = self.cursor() 2787s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2787s c.close() 2787s 2787s if self.init_command is not None: 2787s c = self.cursor() 2787s c.execute(self.init_command) 2787s c.close() 2787s 2787s if self.autocommit_mode is not None: 2787s self.autocommit(self.autocommit_mode) 2787s except BaseException as e: 2787s self._rfile = None 2787s if sock is not None: 2787s try: 2787s sock.close() 2787s except: # noqa 2787s pass 2787s 2787s if isinstance(e, (OSError, IOError)): 2787s exc = err.OperationalError( 2787s CR.CR_CONN_HOST_ERROR, 2787s f"Can't connect to MySQL server on {self.host!r} ({e})", 2787s ) 2787s # Keep original exception and traceback to investigate error. 2787s exc.original_exception = e 2787s exc.traceback = traceback.format_exc() 2787s if DEBUG: 2787s print(exc.traceback) 2787s > raise exc 2787s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2787s _______ ERROR at teardown of test_api_to_sql[postgresql_psycopg2_engine] _______ 2787s self = 2787s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2787s connection = None, _has_events = None, _allow_revalidate = True 2787s _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def postgresql_psycopg2_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2787s td.versioned_importorskip("psycopg2") 2787s engine = sqlalchemy.create_engine( 2787s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2787s poolclass=sqlalchemy.pool.NullPool, 2787s ) 2787s yield engine 2787s > for view in get_all_views(engine): 2787s 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2787s return inspect(conn).get_view_names() 2787s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2787s ret = reg(subject) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2787s return Inspector._construct(Inspector._init_engine, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2787s init(self, bind) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2787s engine.connect().close() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2787s return self._connection_cls(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2787s Connection._handle_dbapi_exception_noconnection( 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2787s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2787s self._dbapi_connection = engine.raw_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s E 2787s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s ________ ERROR at teardown of test_api_to_sql[postgresql_psycopg2_conn] ________ 2787s self = 2787s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2787s connection = None, _has_events = None, _allow_revalidate = True 2787s _allow_autobegin = True 2787s 2787s def __init__( 2787s self, 2787s engine: Engine, 2787s connection: Optional[PoolProxiedConnection] = None, 2787s _has_events: Optional[bool] = None, 2787s _allow_revalidate: bool = True, 2787s _allow_autobegin: bool = True, 2787s ): 2787s """Construct a new Connection.""" 2787s self.engine = engine 2787s self.dialect = dialect = engine.dialect 2787s 2787s if connection is None: 2787s try: 2787s > self._dbapi_connection = engine.raw_connection() 2787s 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2787s return self.pool.connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2787s return _ConnectionFairy._checkout(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2787s fairy = _ConnectionRecord.checkout(pool) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2787s rec = pool._do_get() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2787s return self._create_connection() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2787s return _ConnectionRecord(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2787s self.__connect() 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2787s with util.safe_reraise(): 2787s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2787s raise exc_value.with_traceback(exc_tb) 2787s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2787s self.dbapi_connection = connection = pool._invoke_creator(self) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2787s return dialect.connect(*cargs, **cparams) 2787s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2787s return self.loaded_dbapi.connect(*cargs, **cparams) 2787s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2787s 2787s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2787s connection_factory = None, cursor_factory = None 2787s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2787s kwasync = {} 2787s 2787s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2787s """ 2787s Create a new database connection. 2787s 2787s The connection parameters can be specified as a string: 2787s 2787s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2787s 2787s or using a set of keyword arguments: 2787s 2787s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2787s 2787s Or as a mix of both. The basic connection parameters are: 2787s 2787s - *dbname*: the database name 2787s - *database*: the database name (only as keyword argument) 2787s - *user*: user name used to authenticate 2787s - *password*: password used to authenticate 2787s - *host*: database host address (defaults to UNIX socket if not provided) 2787s - *port*: connection port number (defaults to 5432 if not provided) 2787s 2787s Using the *connection_factory* parameter a different class or connections 2787s factory can be specified. It should be a callable object taking a dsn 2787s argument. 2787s 2787s Using the *cursor_factory* parameter, a new default cursor factory will be 2787s used by cursor(). 2787s 2787s Using *async*=True an asynchronous connection will be created. *async_* is 2787s a valid alias (for Python versions where ``async`` is a keyword). 2787s 2787s Any other keyword parameter will be passed to the underlying client 2787s library: the list of supported parameters depends on the library version. 2787s 2787s """ 2787s kwasync = {} 2787s if 'async' in kwargs: 2787s kwasync['async'] = kwargs.pop('async') 2787s if 'async_' in kwargs: 2787s kwasync['async_'] = kwargs.pop('async_') 2787s 2787s dsn = _ext.make_dsn(dsn, **kwargs) 2787s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2787s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2787s E Is the server running on that host and accepting TCP/IP connections? 2787s 2787s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2787s 2787s The above exception was the direct cause of the following exception: 2787s 2787s @pytest.fixture 2787s def postgresql_psycopg2_engine(): 2787s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _______ ERROR at teardown of test_api_to_sql_fail[mysql_pymysql_engine] ________ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s ________ ERROR at teardown of test_api_to_sql_fail[mysql_pymysql_conn] _________ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s ____ ERROR at teardown of test_api_to_sql_fail[postgresql_psycopg2_engine] _____ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _____ ERROR at teardown of test_api_to_sql_fail[postgresql_psycopg2_conn] ______ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ______ ERROR at teardown of test_api_to_sql_replace[mysql_pymysql_engine] ______ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _______ ERROR at teardown of test_api_to_sql_replace[mysql_pymysql_conn] _______ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s ___ ERROR at teardown of test_api_to_sql_replace[postgresql_psycopg2_engine] ___ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ____ ERROR at teardown of test_api_to_sql_replace[postgresql_psycopg2_conn] ____ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ______ ERROR at teardown of test_api_to_sql_append[mysql_pymysql_engine] _______ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _______ ERROR at teardown of test_api_to_sql_append[mysql_pymysql_conn] ________ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s ___ ERROR at teardown of test_api_to_sql_append[postgresql_psycopg2_engine] ____ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ____ ERROR at teardown of test_api_to_sql_append[postgresql_psycopg2_conn] _____ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ___ ERROR at teardown of test_api_to_sql_type_mapping[mysql_pymysql_engine] ____ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s ____ ERROR at teardown of test_api_to_sql_type_mapping[mysql_pymysql_conn] _____ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_to_sql_type_mapping[postgresql_psycopg2_engine] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_api_to_sql_type_mapping[postgresql_psycopg2_conn] __ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ______ ERROR at teardown of test_api_to_sql_series[mysql_pymysql_engine] _______ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _______ ERROR at teardown of test_api_to_sql_series[mysql_pymysql_conn] ________ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s ___ ERROR at teardown of test_api_to_sql_series[postgresql_psycopg2_engine] ____ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ____ ERROR at teardown of test_api_to_sql_series[postgresql_psycopg2_conn] _____ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ________ ERROR at teardown of test_api_roundtrip[mysql_pymysql_engine] _________ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _________ ERROR at teardown of test_api_roundtrip[mysql_pymysql_conn] __________ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _____ ERROR at teardown of test_api_roundtrip[postgresql_psycopg2_engine] ______ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ______ ERROR at teardown of test_api_roundtrip[postgresql_psycopg2_conn] _______ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ___ ERROR at teardown of test_api_roundtrip_chunksize[mysql_pymysql_engine] ____ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s ____ ERROR at teardown of test_api_roundtrip_chunksize[mysql_pymysql_conn] _____ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_roundtrip_chunksize[postgresql_psycopg2_engine] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_api_roundtrip_chunksize[postgresql_psycopg2_conn] __ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _____ ERROR at teardown of test_api_execute_sql[mysql_pymysql_engine_iris] _____ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s ______ ERROR at teardown of test_api_execute_sql[mysql_pymysql_conn_iris] ______ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s __ ERROR at teardown of test_api_execute_sql[postgresql_psycopg2_engine_iris] __ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ___ ERROR at teardown of test_api_execute_sql[postgresql_psycopg2_conn_iris] ___ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ____ ERROR at teardown of test_api_date_parsing[mysql_pymysql_engine_types] ____ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _____ ERROR at teardown of test_api_date_parsing[mysql_pymysql_conn_types] _____ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_date_parsing[postgresql_psycopg2_engine_types] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s __ ERROR at teardown of test_api_date_parsing[postgresql_psycopg2_conn_types] __ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-mysql_pymysql_engine_types] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-mysql_pymysql_conn_types] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-postgresql_psycopg2_engine_types] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-postgresql_psycopg2_conn_types] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-mysql_pymysql_engine_types] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-mysql_pymysql_conn_types] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-postgresql_psycopg2_engine_types] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-postgresql_psycopg2_conn_types] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-mysql_pymysql_engine_types] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-mysql_pymysql_conn_types] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-postgresql_psycopg2_engine_types] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-postgresql_psycopg2_conn_types] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-mysql_pymysql_engine_types] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-mysql_pymysql_conn_types] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-postgresql_psycopg2_engine_types] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-postgresql_psycopg2_conn_types] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-mysql_pymysql_engine_types] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-mysql_pymysql_conn_types] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-postgresql_psycopg2_engine_types] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-postgresql_psycopg2_conn_types] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-mysql_pymysql_engine_types] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-mysql_pymysql_conn_types] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-postgresql_psycopg2_engine_types] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-postgresql_psycopg2_conn_types] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-mysql_pymysql_engine_types] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-mysql_pymysql_conn_types] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-postgresql_psycopg2_engine_types] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-postgresql_psycopg2_conn_types] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-mysql_pymysql_engine_types] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-mysql_pymysql_conn_types] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-postgresql_psycopg2_engine_types] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-postgresql_psycopg2_conn_types] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-mysql_pymysql_engine_types] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-mysql_pymysql_conn_types] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-postgresql_psycopg2_engine_types] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-postgresql_psycopg2_conn_types] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-mysql_pymysql_engine_types] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-mysql_pymysql_conn_types] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-postgresql_psycopg2_engine_types] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-postgresql_psycopg2_conn_types] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-mysql_pymysql_engine_types] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-mysql_pymysql_conn_types] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-postgresql_psycopg2_engine_types] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-postgresql_psycopg2_conn_types] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-mysql_pymysql_engine_types] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-mysql_pymysql_conn_types] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-postgresql_psycopg2_engine_types] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-postgresql_psycopg2_conn_types] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ___ ERROR at teardown of test_api_date_and_index[mysql_pymysql_engine_types] ___ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s ____ ERROR at teardown of test_api_date_and_index[mysql_pymysql_conn_types] ____ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_date_and_index[postgresql_psycopg2_engine_types] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_api_date_and_index[postgresql_psycopg2_conn_types] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ________ ERROR at teardown of test_api_timedelta[mysql_pymysql_engine] _________ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _________ ERROR at teardown of test_api_timedelta[mysql_pymysql_conn] __________ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _____ ERROR at teardown of test_api_timedelta[postgresql_psycopg2_engine] ______ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ______ ERROR at teardown of test_api_timedelta[postgresql_psycopg2_conn] _______ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ______ ERROR at teardown of test_api_complex_raises[mysql_pymysql_engine] ______ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _______ ERROR at teardown of test_api_complex_raises[mysql_pymysql_conn] _______ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s ___ ERROR at teardown of test_api_complex_raises[postgresql_psycopg2_engine] ___ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ____ ERROR at teardown of test_api_complex_raises[postgresql_psycopg2_conn] ____ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_api_to_sql_index_label[None-None-index-mysql_pymysql_engine] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_to_sql_index_label[None-None-index-mysql_pymysql_conn] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_engine] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_conn] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_api_to_sql_index_label[None-other_label-other_label-mysql_pymysql_engine] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_to_sql_index_label[None-other_label-other_label-mysql_pymysql_conn] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_to_sql_index_label[None-other_label-other_label-postgresql_psycopg2_engine] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_api_to_sql_index_label[None-other_label-other_label-postgresql_psycopg2_conn] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_api_to_sql_index_label[index_name-None-index_name-mysql_pymysql_engine] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_to_sql_index_label[index_name-None-index_name-mysql_pymysql_conn] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_to_sql_index_label[index_name-None-index_name-postgresql_psycopg2_engine] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_api_to_sql_index_label[index_name-None-index_name-postgresql_psycopg2_conn] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_api_to_sql_index_label[index_name-other_label-other_label-mysql_pymysql_engine] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_to_sql_index_label[index_name-other_label-other_label-mysql_pymysql_conn] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_to_sql_index_label[index_name-other_label-other_label-postgresql_psycopg2_engine] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_api_to_sql_index_label[index_name-other_label-other_label-postgresql_psycopg2_conn] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_api_to_sql_index_label[0-None-0-mysql_pymysql_engine] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_to_sql_index_label[0-None-0-mysql_pymysql_conn] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_engine] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_conn] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_api_to_sql_index_label[None-0-0-mysql_pymysql_engine] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_to_sql_index_label[None-0-0-mysql_pymysql_conn] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_engine] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_conn] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_api_to_sql_index_label_multiindex[postgresql_psycopg2_engine] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_api_to_sql_index_label_multiindex[postgresql_psycopg2_conn] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ___ ERROR at teardown of test_api_multiindex_roundtrip[mysql_pymysql_engine] ___ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s ____ ERROR at teardown of test_api_multiindex_roundtrip[mysql_pymysql_conn] ____ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_multiindex_roundtrip[postgresql_psycopg2_engine] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_api_multiindex_roundtrip[postgresql_psycopg2_conn] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ___ ERROR at teardown of test_api_dtype_argument[None-mysql_pymysql_engine] ____ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s ____ ERROR at teardown of test_api_dtype_argument[None-mysql_pymysql_conn] _____ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_dtype_argument[None-postgresql_psycopg2_engine] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_api_dtype_argument[None-postgresql_psycopg2_conn] __ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ____ ERROR at teardown of test_api_dtype_argument[int-mysql_pymysql_engine] ____ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _____ ERROR at teardown of test_api_dtype_argument[int-mysql_pymysql_conn] _____ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_dtype_argument[int-postgresql_psycopg2_engine] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s __ ERROR at teardown of test_api_dtype_argument[int-postgresql_psycopg2_conn] __ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ___ ERROR at teardown of test_api_dtype_argument[float-mysql_pymysql_engine] ___ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s ____ ERROR at teardown of test_api_dtype_argument[float-mysql_pymysql_conn] ____ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_dtype_argument[float-postgresql_psycopg2_engine] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_api_dtype_argument[float-postgresql_psycopg2_conn] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s __ ERROR at teardown of test_api_dtype_argument[dtype3-mysql_pymysql_engine] ___ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s ___ ERROR at teardown of test_api_dtype_argument[dtype3-mysql_pymysql_conn] ____ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_dtype_argument[dtype3-postgresql_psycopg2_engine] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_api_dtype_argument[dtype3-postgresql_psycopg2_conn] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ____ ERROR at teardown of test_api_integer_col_names[mysql_pymysql_engine] _____ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _____ ERROR at teardown of test_api_integer_col_names[mysql_pymysql_conn] ______ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_integer_col_names[postgresql_psycopg2_engine] __ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s __ ERROR at teardown of test_api_integer_col_names[postgresql_psycopg2_conn] ___ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ________ ERROR at teardown of test_api_get_schema[mysql_pymysql_engine] ________ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _________ ERROR at teardown of test_api_get_schema[mysql_pymysql_conn] _________ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _____ ERROR at teardown of test_api_get_schema[postgresql_psycopg2_engine] _____ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ______ ERROR at teardown of test_api_get_schema[postgresql_psycopg2_conn] ______ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s __ ERROR at teardown of test_api_get_schema_with_schema[mysql_pymysql_engine] __ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s ___ ERROR at teardown of test_api_get_schema_with_schema[mysql_pymysql_conn] ___ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_get_schema_with_schema[postgresql_psycopg2_engine] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_api_get_schema_with_schema[postgresql_psycopg2_conn] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ____ ERROR at teardown of test_api_get_schema_dtypes[mysql_pymysql_engine] _____ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _____ ERROR at teardown of test_api_get_schema_dtypes[mysql_pymysql_conn] ______ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_get_schema_dtypes[postgresql_psycopg2_engine] __ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s __ ERROR at teardown of test_api_get_schema_dtypes[postgresql_psycopg2_conn] ___ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _____ ERROR at teardown of test_api_get_schema_keys[mysql_pymysql_engine] ______ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s ______ ERROR at teardown of test_api_get_schema_keys[mysql_pymysql_conn] _______ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s __ ERROR at teardown of test_api_get_schema_keys[postgresql_psycopg2_engine] ___ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ___ ERROR at teardown of test_api_get_schema_keys[postgresql_psycopg2_conn] ____ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ______ ERROR at teardown of test_api_chunksize_read[mysql_pymysql_engine] ______ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _______ ERROR at teardown of test_api_chunksize_read[mysql_pymysql_conn] _______ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s ___ ERROR at teardown of test_api_chunksize_read[postgresql_psycopg2_engine] ___ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ____ ERROR at teardown of test_api_chunksize_read[postgresql_psycopg2_conn] ____ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _______ ERROR at teardown of test_api_categorical[mysql_pymysql_engine] ________ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s ________ ERROR at teardown of test_api_categorical[mysql_pymysql_conn] _________ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s ____ ERROR at teardown of test_api_categorical[postgresql_psycopg2_engine] _____ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _____ ERROR at teardown of test_api_categorical[postgresql_psycopg2_conn] ______ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ___ ERROR at teardown of test_api_unicode_column_name[mysql_pymysql_engine] ____ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s ____ ERROR at teardown of test_api_unicode_column_name[mysql_pymysql_conn] _____ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_unicode_column_name[postgresql_psycopg2_engine] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_api_unicode_column_name[postgresql_psycopg2_conn] __ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ____ ERROR at teardown of test_api_escaped_table_name[mysql_pymysql_engine] ____ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _____ ERROR at teardown of test_api_escaped_table_name[mysql_pymysql_conn] _____ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_escaped_table_name[postgresql_psycopg2_engine] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s __ ERROR at teardown of test_api_escaped_table_name[postgresql_psycopg2_conn] __ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_api_read_sql_duplicate_columns[mysql_pymysql_engine] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_read_sql_duplicate_columns[mysql_pymysql_conn] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_api_read_sql_duplicate_columns[postgresql_psycopg2_engine] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_api_read_sql_duplicate_columns[postgresql_psycopg2_conn] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ______ ERROR at teardown of test_read_table_columns[mysql_pymysql_engine] ______ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _______ ERROR at teardown of test_read_table_columns[mysql_pymysql_conn] _______ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s ___ ERROR at teardown of test_read_table_columns[postgresql_psycopg2_engine] ___ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ____ ERROR at teardown of test_read_table_columns[postgresql_psycopg2_conn] ____ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _____ ERROR at teardown of test_read_table_index_col[mysql_pymysql_engine] _____ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s ______ ERROR at teardown of test_read_table_index_col[mysql_pymysql_conn] ______ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s __ ERROR at teardown of test_read_table_index_col[postgresql_psycopg2_engine] __ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ___ ERROR at teardown of test_read_table_index_col[postgresql_psycopg2_conn] ___ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ____ ERROR at teardown of test_read_sql_delegate[mysql_pymysql_engine_iris] ____ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _____ ERROR at teardown of test_read_sql_delegate[mysql_pymysql_conn_iris] _____ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_read_sql_delegate[postgresql_psycopg2_engine_iris] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s __ ERROR at teardown of test_read_sql_delegate[postgresql_psycopg2_conn_iris] __ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_warning_case_insensitive_table_name[mysql_pymysql_engine] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_warning_case_insensitive_table_name[mysql_pymysql_conn] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_warning_case_insensitive_table_name[postgresql_psycopg2_engine] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_warning_case_insensitive_table_name[postgresql_psycopg2_conn] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ___ ERROR at teardown of test_sqlalchemy_type_mapping[mysql_pymysql_engine] ____ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s ____ ERROR at teardown of test_sqlalchemy_type_mapping[mysql_pymysql_conn] _____ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_type_mapping[postgresql_psycopg2_engine] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_type_mapping[postgresql_psycopg2_conn] __ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_engine] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_conn] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_engine] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_conn] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_engine] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_conn] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_engine] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_conn] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_engine] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_conn] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_engine] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_conn] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_engine] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_conn] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_engine] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_conn] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_engine] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_conn] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_engine] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_conn] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_engine] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_conn] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_engine] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_conn] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_engine] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_conn] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_engine] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_conn] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_engine] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_conn] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_engine] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_conn] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_engine] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_conn] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_engine] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_conn] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_engine] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_conn] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_engine] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_conn] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_engine] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_conn] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_engine] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_conn] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_engine] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_conn] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_engine] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_conn] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_engine] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_conn] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_engine] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_conn] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_engine] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_conn] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_engine] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_conn] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int-INTEGER-mysql_pymysql_engine] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int-INTEGER-mysql_pymysql_conn] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int-INTEGER-postgresql_psycopg2_engine] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int-INTEGER-postgresql_psycopg2_conn] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_engine] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_conn] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_engine] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_conn] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_engine] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_conn] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_engine] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_conn] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _____ ERROR at teardown of test_database_uri_string[mysql_pymysql_engine] ______ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s ______ ERROR at teardown of test_database_uri_string[mysql_pymysql_conn] _______ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s __ ERROR at teardown of test_database_uri_string[postgresql_psycopg2_engine] ___ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ___ ERROR at teardown of test_database_uri_string[postgresql_psycopg2_conn] ____ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_pg8000_sqlalchemy_passthrough_error[mysql_pymysql_engine] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_pg8000_sqlalchemy_passthrough_error[mysql_pymysql_conn] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_pg8000_sqlalchemy_passthrough_error[postgresql_psycopg2_engine] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_pg8000_sqlalchemy_passthrough_error[postgresql_psycopg2_conn] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ____ ERROR at teardown of test_query_by_text_obj[mysql_pymysql_engine_iris] ____ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _____ ERROR at teardown of test_query_by_text_obj[mysql_pymysql_conn_iris] _____ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_query_by_text_obj[postgresql_psycopg2_engine_iris] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s __ ERROR at teardown of test_query_by_text_obj[postgresql_psycopg2_conn_iris] __ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ___ ERROR at teardown of test_query_by_select_obj[mysql_pymysql_engine_iris] ___ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s ____ ERROR at teardown of test_query_by_select_obj[mysql_pymysql_conn_iris] ____ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_query_by_select_obj[postgresql_psycopg2_engine_iris] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_query_by_select_obj[postgresql_psycopg2_conn_iris] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ____ ERROR at teardown of test_column_with_percentage[mysql_pymysql_engine] ____ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _____ ERROR at teardown of test_column_with_percentage[mysql_pymysql_conn] _____ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_column_with_percentage[postgresql_psycopg2_engine] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s __ ERROR at teardown of test_column_with_percentage[postgresql_psycopg2_conn] __ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _________ ERROR at teardown of test_create_table[mysql_pymysql_engine] _________ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s __________ ERROR at teardown of test_create_table[mysql_pymysql_conn] __________ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s ______ ERROR at teardown of test_create_table[postgresql_psycopg2_engine] ______ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _______ ERROR at teardown of test_create_table[postgresql_psycopg2_conn] _______ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s __________ ERROR at teardown of test_drop_table[mysql_pymysql_engine] __________ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s ___________ ERROR at teardown of test_drop_table[mysql_pymysql_conn] ___________ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _______ ERROR at teardown of test_drop_table[postgresql_psycopg2_engine] _______ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ________ ERROR at teardown of test_drop_table[postgresql_psycopg2_conn] ________ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s __________ ERROR at teardown of test_roundtrip[mysql_pymysql_engine] ___________ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s ___________ ERROR at teardown of test_roundtrip[mysql_pymysql_conn] ____________ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _______ ERROR at teardown of test_roundtrip[postgresql_psycopg2_engine] ________ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ________ ERROR at teardown of test_roundtrip[postgresql_psycopg2_conn] _________ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _______ ERROR at teardown of test_execute_sql[mysql_pymysql_engine_iris] _______ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s ________ ERROR at teardown of test_execute_sql[mysql_pymysql_conn_iris] ________ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s ____ ERROR at teardown of test_execute_sql[postgresql_psycopg2_engine_iris] ____ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _____ ERROR at teardown of test_execute_sql[postgresql_psycopg2_conn_iris] _____ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s __ ERROR at teardown of test_sqlalchemy_read_table[mysql_pymysql_engine_iris] __ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s ___ ERROR at teardown of test_sqlalchemy_read_table[mysql_pymysql_conn_iris] ___ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_read_table[postgresql_psycopg2_engine_iris] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_read_table[postgresql_psycopg2_conn_iris] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_read_table_columns[mysql_pymysql_engine_iris] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_read_table_columns[mysql_pymysql_conn_iris] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_read_table_columns[postgresql_psycopg2_engine_iris] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_read_table_columns[postgresql_psycopg2_conn_iris] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_read_table_absent_raises[mysql_pymysql_engine_iris] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_read_table_absent_raises[mysql_pymysql_conn_iris] __ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_read_table_absent_raises[postgresql_psycopg2_engine_iris] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_read_table_absent_raises[postgresql_psycopg2_conn_iris] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_default_type_conversion[postgresql_psycopg2_engine_types] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_sqlalchemy_default_type_conversion[postgresql_psycopg2_conn_types] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ____________ ERROR at teardown of test_bigint[mysql_pymysql_engine] ____________ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _____________ ERROR at teardown of test_bigint[mysql_pymysql_conn] _____________ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _________ ERROR at teardown of test_bigint[postgresql_psycopg2_engine] _________ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s __________ ERROR at teardown of test_bigint[postgresql_psycopg2_conn] __________ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ___ ERROR at teardown of test_default_date_load[mysql_pymysql_engine_types] ____ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s ____ ERROR at teardown of test_default_date_load[mysql_pymysql_conn_types] _____ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_default_date_load[postgresql_psycopg2_engine_types] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_default_date_load[postgresql_psycopg2_conn_types] __ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_datetime_with_timezone_query[None-postgresql_psycopg2_engine] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_datetime_with_timezone_query[None-postgresql_psycopg2_conn] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_engine] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_conn] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_engine] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_conn] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_datetime_with_timezone_table[postgresql_psycopg2_engine] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_datetime_with_timezone_table[postgresql_psycopg2_conn] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_datetime_with_timezone_roundtrip[mysql_pymysql_engine] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_datetime_with_timezone_roundtrip[mysql_pymysql_conn] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_datetime_with_timezone_roundtrip[postgresql_psycopg2_engine] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_datetime_with_timezone_roundtrip[postgresql_psycopg2_conn] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ____ ERROR at teardown of test_out_of_bounds_datetime[mysql_pymysql_engine] ____ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _____ ERROR at teardown of test_out_of_bounds_datetime[mysql_pymysql_conn] _____ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_out_of_bounds_datetime[postgresql_psycopg2_engine] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s __ ERROR at teardown of test_out_of_bounds_datetime[postgresql_psycopg2_conn] __ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_naive_datetimeindex_roundtrip[mysql_pymysql_engine] _ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_naive_datetimeindex_roundtrip[mysql_pymysql_conn] __ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_naive_datetimeindex_roundtrip[postgresql_psycopg2_engine] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_naive_datetimeindex_roundtrip[postgresql_psycopg2_conn] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ______ ERROR at teardown of test_date_parsing[mysql_pymysql_engine_types] ______ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _______ ERROR at teardown of test_date_parsing[mysql_pymysql_conn_types] _______ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s ___ ERROR at teardown of test_date_parsing[postgresql_psycopg2_engine_types] ___ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ____ ERROR at teardown of test_date_parsing[postgresql_psycopg2_conn_types] ____ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ___________ ERROR at teardown of test_datetime[mysql_pymysql_engine] ___________ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s ____________ ERROR at teardown of test_datetime[mysql_pymysql_conn] ____________ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s ________ ERROR at teardown of test_datetime[postgresql_psycopg2_engine] ________ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _________ ERROR at teardown of test_datetime[postgresql_psycopg2_conn] _________ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _________ ERROR at teardown of test_datetime_NaT[mysql_pymysql_engine] _________ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s __________ ERROR at teardown of test_datetime_NaT[mysql_pymysql_conn] __________ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s ______ ERROR at teardown of test_datetime_NaT[postgresql_psycopg2_engine] ______ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _______ ERROR at teardown of test_datetime_NaT[postgresql_psycopg2_conn] _______ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ________ ERROR at teardown of test_datetime_date[mysql_pymysql_engine] _________ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _________ ERROR at teardown of test_datetime_date[mysql_pymysql_conn] __________ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _____ ERROR at teardown of test_datetime_date[postgresql_psycopg2_engine] ______ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ______ ERROR at teardown of test_datetime_date[postgresql_psycopg2_conn] _______ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ________ ERROR at teardown of test_datetime_time[mysql_pymysql_engine] _________ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _________ ERROR at teardown of test_datetime_time[mysql_pymysql_conn] __________ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _____ ERROR at teardown of test_datetime_time[postgresql_psycopg2_engine] ______ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ______ ERROR at teardown of test_datetime_time[postgresql_psycopg2_conn] _______ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ______ ERROR at teardown of test_mixed_dtype_insert[mysql_pymysql_engine] ______ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _______ ERROR at teardown of test_mixed_dtype_insert[mysql_pymysql_conn] _______ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s ___ ERROR at teardown of test_mixed_dtype_insert[postgresql_psycopg2_engine] ___ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ____ ERROR at teardown of test_mixed_dtype_insert[postgresql_psycopg2_conn] ____ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _________ ERROR at teardown of test_nan_numeric[mysql_pymysql_engine] __________ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s __________ ERROR at teardown of test_nan_numeric[mysql_pymysql_conn] ___________ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s ______ ERROR at teardown of test_nan_numeric[postgresql_psycopg2_engine] _______ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _______ ERROR at teardown of test_nan_numeric[postgresql_psycopg2_conn] ________ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ________ ERROR at teardown of test_nan_fullcolumn[mysql_pymysql_engine] ________ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _________ ERROR at teardown of test_nan_fullcolumn[mysql_pymysql_conn] _________ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _____ ERROR at teardown of test_nan_fullcolumn[postgresql_psycopg2_engine] _____ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ______ ERROR at teardown of test_nan_fullcolumn[postgresql_psycopg2_conn] ______ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s __________ ERROR at teardown of test_nan_string[mysql_pymysql_engine] __________ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s ___________ ERROR at teardown of test_nan_string[mysql_pymysql_conn] ___________ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _______ ERROR at teardown of test_nan_string[postgresql_psycopg2_engine] _______ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ________ ERROR at teardown of test_nan_string[postgresql_psycopg2_conn] ________ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ______ ERROR at teardown of test_to_sql_save_index[mysql_pymysql_engine] _______ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _______ ERROR at teardown of test_to_sql_save_index[mysql_pymysql_conn] ________ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s ___ ERROR at teardown of test_to_sql_save_index[postgresql_psycopg2_engine] ____ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ____ ERROR at teardown of test_to_sql_save_index[postgresql_psycopg2_conn] _____ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _________ ERROR at teardown of test_transactions[mysql_pymysql_engine] _________ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s __________ ERROR at teardown of test_transactions[mysql_pymysql_conn] __________ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s ______ ERROR at teardown of test_transactions[postgresql_psycopg2_engine] ______ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _______ ERROR at teardown of test_transactions[postgresql_psycopg2_conn] _______ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _____ ERROR at teardown of test_transaction_rollback[mysql_pymysql_engine] _____ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s ______ ERROR at teardown of test_transaction_rollback[mysql_pymysql_conn] ______ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s __ ERROR at teardown of test_transaction_rollback[postgresql_psycopg2_engine] __ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ___ ERROR at teardown of test_transaction_rollback[postgresql_psycopg2_conn] ___ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ___ ERROR at teardown of test_get_schema_create_table[mysql_pymysql_engine] ____ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s ____ ERROR at teardown of test_get_schema_create_table[mysql_pymysql_conn] _____ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _ ERROR at teardown of test_get_schema_create_table[postgresql_psycopg2_engine] _ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s _ ERROR at teardown of test_get_schema_create_table[postgresql_psycopg2_conn] __ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s ____________ ERROR at teardown of test_dtype[mysql_pymysql_engine] _____________ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _____________ ERROR at teardown of test_dtype[mysql_pymysql_conn] ______________ 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s > sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3.13/socket.py:864: in create_connection 2788s raise exceptions[0] 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s address = ('localhost', 3306), timeout = 10, source_address = None 2788s 2788s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2788s source_address=None, *, all_errors=False): 2788s """Connect to *address* and return the socket object. 2788s 2788s Convenience function. Connect to *address* (a 2-tuple ``(host, 2788s port)``) and return the socket object. Passing the optional 2788s *timeout* parameter will set the timeout on the socket instance 2788s before attempting to connect. If no *timeout* is supplied, the 2788s global default timeout setting returned by :func:`getdefaulttimeout` 2788s is used. If *source_address* is set it must be a tuple of (host, port) 2788s for the socket to bind as a source address before making the connection. 2788s A host of '' or port 0 tells the OS to use the default. When a connection 2788s cannot be created, raises the last error if *all_errors* is False, 2788s and an ExceptionGroup of all errors if *all_errors* is True. 2788s """ 2788s 2788s host, port = address 2788s exceptions = [] 2788s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2788s af, socktype, proto, canonname, sa = res 2788s sock = None 2788s try: 2788s sock = socket(af, socktype, proto) 2788s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2788s sock.settimeout(timeout) 2788s if source_address: 2788s sock.bind(source_address) 2788s > sock.connect(sa) 2788s E ConnectionRefusedError: [Errno 111] Connection refused 2788s 2788s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2788s 2788s During handling of the above exception, another exception occurred: 2788s 2788s self = 2788s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2788s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def mysql_pymysql_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s pymysql = td.versioned_importorskip("pymysql") 2788s engine = sqlalchemy.create_engine( 2788s "mysql+pymysql://root@localhost:3306/pandas", 2788s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2788s self.connect() 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s self = , sock = None 2788s 2788s def connect(self, sock=None): 2788s self._closed = False 2788s try: 2788s if sock is None: 2788s if self.unix_socket: 2788s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2788s sock.settimeout(self.connect_timeout) 2788s sock.connect(self.unix_socket) 2788s self.host_info = "Localhost via UNIX socket" 2788s self._secure = True 2788s if DEBUG: 2788s print("connected using unix_socket") 2788s else: 2788s kwargs = {} 2788s if self.bind_address is not None: 2788s kwargs["source_address"] = (self.bind_address, 0) 2788s while True: 2788s try: 2788s sock = socket.create_connection( 2788s (self.host, self.port), self.connect_timeout, **kwargs 2788s ) 2788s break 2788s except OSError as e: 2788s if e.errno == errno.EINTR: 2788s continue 2788s raise 2788s self.host_info = "socket %s:%d" % (self.host, self.port) 2788s if DEBUG: 2788s print("connected using socket") 2788s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2788s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2788s sock.settimeout(None) 2788s 2788s self._sock = sock 2788s self._rfile = sock.makefile("rb") 2788s self._next_seq_id = 0 2788s 2788s self._get_server_information() 2788s self._request_authentication() 2788s 2788s # Send "SET NAMES" query on init for: 2788s # - Ensure charaset (and collation) is set to the server. 2788s # - collation_id in handshake packet may be ignored. 2788s # - If collation is not specified, we don't know what is server's 2788s # default collation for the charset. For example, default collation 2788s # of utf8mb4 is: 2788s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2788s # - MySQL 8.0: utf8mb4_0900_ai_ci 2788s # 2788s # Reference: 2788s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2788s # - https://github.com/wagtail/wagtail/issues/9477 2788s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2788s self.set_character_set(self.charset, self.collation) 2788s 2788s if self.sql_mode is not None: 2788s c = self.cursor() 2788s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2788s c.close() 2788s 2788s if self.init_command is not None: 2788s c = self.cursor() 2788s c.execute(self.init_command) 2788s c.close() 2788s 2788s if self.autocommit_mode is not None: 2788s self.autocommit(self.autocommit_mode) 2788s except BaseException as e: 2788s self._rfile = None 2788s if sock is not None: 2788s try: 2788s sock.close() 2788s except: # noqa 2788s pass 2788s 2788s if isinstance(e, (OSError, IOError)): 2788s exc = err.OperationalError( 2788s CR.CR_CONN_HOST_ERROR, 2788s f"Can't connect to MySQL server on {self.host!r} ({e})", 2788s ) 2788s # Keep original exception and traceback to investigate error. 2788s exc.original_exception = e 2788s exc.traceback = traceback.format_exc() 2788s if DEBUG: 2788s print(exc.traceback) 2788s > raise exc 2788s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2788s _________ ERROR at teardown of test_dtype[postgresql_psycopg2_engine] __________ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s 2788s The above exception was the direct cause of the following exception: 2788s 2788s @pytest.fixture 2788s def postgresql_psycopg2_engine(): 2788s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2788s td.versioned_importorskip("psycopg2") 2788s engine = sqlalchemy.create_engine( 2788s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2788s poolclass=sqlalchemy.pool.NullPool, 2788s ) 2788s yield engine 2788s > for view in get_all_views(engine): 2788s 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2788s return inspect(conn).get_view_names() 2788s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2788s ret = reg(subject) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2788s return Inspector._construct(Inspector._init_engine, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2788s init(self, bind) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2788s engine.connect().close() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2788s return self._connection_cls(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2788s Connection._handle_dbapi_exception_noconnection( 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2788s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2788s self._dbapi_connection = engine.raw_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2788s - *port*: connection port number (defaults to 5432 if not provided) 2788s 2788s Using the *connection_factory* parameter a different class or connections 2788s factory can be specified. It should be a callable object taking a dsn 2788s argument. 2788s 2788s Using the *cursor_factory* parameter, a new default cursor factory will be 2788s used by cursor(). 2788s 2788s Using *async*=True an asynchronous connection will be created. *async_* is 2788s a valid alias (for Python versions where ``async`` is a keyword). 2788s 2788s Any other keyword parameter will be passed to the underlying client 2788s library: the list of supported parameters depends on the library version. 2788s 2788s """ 2788s kwasync = {} 2788s if 'async' in kwargs: 2788s kwasync['async'] = kwargs.pop('async') 2788s if 'async_' in kwargs: 2788s kwasync['async_'] = kwargs.pop('async_') 2788s 2788s dsn = _ext.make_dsn(dsn, **kwargs) 2788s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2788s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2788s E Is the server running on that host and accepting TCP/IP connections? 2788s E 2788s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2788s 2788s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2788s __________ ERROR at teardown of test_dtype[postgresql_psycopg2_conn] ___________ 2788s self = 2788s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2788s connection = None, _has_events = None, _allow_revalidate = True 2788s _allow_autobegin = True 2788s 2788s def __init__( 2788s self, 2788s engine: Engine, 2788s connection: Optional[PoolProxiedConnection] = None, 2788s _has_events: Optional[bool] = None, 2788s _allow_revalidate: bool = True, 2788s _allow_autobegin: bool = True, 2788s ): 2788s """Construct a new Connection.""" 2788s self.engine = engine 2788s self.dialect = dialect = engine.dialect 2788s 2788s if connection is None: 2788s try: 2788s > self._dbapi_connection = engine.raw_connection() 2788s 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2788s return self.pool.connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2788s return _ConnectionFairy._checkout(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2788s fairy = _ConnectionRecord.checkout(pool) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2788s rec = pool._do_get() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2788s return self._create_connection() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2788s return _ConnectionRecord(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2788s self.__connect() 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2788s with util.safe_reraise(): 2788s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2788s raise exc_value.with_traceback(exc_tb) 2788s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2788s self.dbapi_connection = connection = pool._invoke_creator(self) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2788s return dialect.connect(*cargs, **cparams) 2788s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2788s return self.loaded_dbapi.connect(*cargs, **cparams) 2788s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2788s 2788s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2788s connection_factory = None, cursor_factory = None 2788s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2788s kwasync = {} 2788s 2788s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2788s """ 2788s Create a new database connection. 2788s 2788s The connection parameters can be specified as a string: 2788s 2788s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2788s 2788s or using a set of keyword arguments: 2788s 2788s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2788s 2788s Or as a mix of both. The basic connection parameters are: 2788s 2788s - *dbname*: the database name 2788s - *database*: the database name (only as keyword argument) 2788s - *user*: user name used to authenticate 2788s - *password*: password used to authenticate 2788s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def postgresql_psycopg2_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s td.versioned_importorskip("psycopg2") 2789s engine = sqlalchemy.create_engine( 2789s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _________ ERROR at teardown of test_notna_dtype[mysql_pymysql_engine] __________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def mysql_pymysql_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s pymysql = td.versioned_importorskip("pymysql") 2789s engine = sqlalchemy.create_engine( 2789s "mysql+pymysql://root@localhost:3306/pandas", 2789s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s __________ ERROR at teardown of test_notna_dtype[mysql_pymysql_conn] ___________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def mysql_pymysql_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s pymysql = td.versioned_importorskip("pymysql") 2789s engine = sqlalchemy.create_engine( 2789s "mysql+pymysql://root@localhost:3306/pandas", 2789s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ______ ERROR at teardown of test_notna_dtype[postgresql_psycopg2_engine] _______ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def postgresql_psycopg2_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s td.versioned_importorskip("psycopg2") 2789s engine = sqlalchemy.create_engine( 2789s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _______ ERROR at teardown of test_notna_dtype[postgresql_psycopg2_conn] ________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def postgresql_psycopg2_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s td.versioned_importorskip("psycopg2") 2789s engine = sqlalchemy.create_engine( 2789s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _______ ERROR at teardown of test_double_precision[mysql_pymysql_engine] _______ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def mysql_pymysql_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s pymysql = td.versioned_importorskip("pymysql") 2789s engine = sqlalchemy.create_engine( 2789s "mysql+pymysql://root@localhost:3306/pandas", 2789s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ________ ERROR at teardown of test_double_precision[mysql_pymysql_conn] ________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def mysql_pymysql_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s pymysql = td.versioned_importorskip("pymysql") 2789s engine = sqlalchemy.create_engine( 2789s "mysql+pymysql://root@localhost:3306/pandas", 2789s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ____ ERROR at teardown of test_double_precision[postgresql_psycopg2_engine] ____ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def postgresql_psycopg2_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s td.versioned_importorskip("psycopg2") 2789s engine = sqlalchemy.create_engine( 2789s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _____ ERROR at teardown of test_double_precision[postgresql_psycopg2_conn] _____ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def postgresql_psycopg2_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s td.versioned_importorskip("psycopg2") 2789s engine = sqlalchemy.create_engine( 2789s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s __ ERROR at teardown of test_connectable_issue_example[mysql_pymysql_engine] ___ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def mysql_pymysql_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s pymysql = td.versioned_importorskip("pymysql") 2789s engine = sqlalchemy.create_engine( 2789s "mysql+pymysql://root@localhost:3306/pandas", 2789s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ___ ERROR at teardown of test_connectable_issue_example[mysql_pymysql_conn] ____ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def mysql_pymysql_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s pymysql = td.versioned_importorskip("pymysql") 2789s engine = sqlalchemy.create_engine( 2789s "mysql+pymysql://root@localhost:3306/pandas", 2789s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ ERROR at teardown of test_connectable_issue_example[postgresql_psycopg2_engine] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def postgresql_psycopg2_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s td.versioned_importorskip("psycopg2") 2789s engine = sqlalchemy.create_engine( 2789s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ ERROR at teardown of test_connectable_issue_example[postgresql_psycopg2_conn] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def postgresql_psycopg2_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s td.versioned_importorskip("psycopg2") 2789s engine = sqlalchemy.create_engine( 2789s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ ERROR at teardown of test_to_sql_with_negative_npinf[input0-mysql_pymysql_engine] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def mysql_pymysql_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s pymysql = td.versioned_importorskip("pymysql") 2789s engine = sqlalchemy.create_engine( 2789s "mysql+pymysql://root@localhost:3306/pandas", 2789s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ ERROR at teardown of test_to_sql_with_negative_npinf[input0-mysql_pymysql_conn] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def mysql_pymysql_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s pymysql = td.versioned_importorskip("pymysql") 2789s engine = sqlalchemy.create_engine( 2789s "mysql+pymysql://root@localhost:3306/pandas", 2789s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ ERROR at teardown of test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_engine] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def postgresql_psycopg2_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s td.versioned_importorskip("psycopg2") 2789s engine = sqlalchemy.create_engine( 2789s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ ERROR at teardown of test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_conn] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def postgresql_psycopg2_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s td.versioned_importorskip("psycopg2") 2789s engine = sqlalchemy.create_engine( 2789s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ ERROR at teardown of test_to_sql_with_negative_npinf[input1-mysql_pymysql_engine] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def mysql_pymysql_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s pymysql = td.versioned_importorskip("pymysql") 2789s engine = sqlalchemy.create_engine( 2789s "mysql+pymysql://root@localhost:3306/pandas", 2789s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ ERROR at teardown of test_to_sql_with_negative_npinf[input1-mysql_pymysql_conn] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def mysql_pymysql_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s pymysql = td.versioned_importorskip("pymysql") 2789s engine = sqlalchemy.create_engine( 2789s "mysql+pymysql://root@localhost:3306/pandas", 2789s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ ERROR at teardown of test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_engine] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def postgresql_psycopg2_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s td.versioned_importorskip("psycopg2") 2789s engine = sqlalchemy.create_engine( 2789s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ ERROR at teardown of test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_conn] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def postgresql_psycopg2_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s td.versioned_importorskip("psycopg2") 2789s engine = sqlalchemy.create_engine( 2789s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ ERROR at teardown of test_to_sql_with_negative_npinf[input2-mysql_pymysql_engine] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def mysql_pymysql_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s pymysql = td.versioned_importorskip("pymysql") 2789s engine = sqlalchemy.create_engine( 2789s "mysql+pymysql://root@localhost:3306/pandas", 2789s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ ERROR at teardown of test_to_sql_with_negative_npinf[input2-mysql_pymysql_conn] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def mysql_pymysql_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s pymysql = td.versioned_importorskip("pymysql") 2789s engine = sqlalchemy.create_engine( 2789s "mysql+pymysql://root@localhost:3306/pandas", 2789s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ ERROR at teardown of test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_engine] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def postgresql_psycopg2_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s td.versioned_importorskip("psycopg2") 2789s engine = sqlalchemy.create_engine( 2789s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ ERROR at teardown of test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_conn] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def postgresql_psycopg2_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s td.versioned_importorskip("psycopg2") 2789s engine = sqlalchemy.create_engine( 2789s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _______ ERROR at teardown of test_temporary_table[mysql_pymysql_engine] ________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def mysql_pymysql_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s pymysql = td.versioned_importorskip("pymysql") 2789s engine = sqlalchemy.create_engine( 2789s "mysql+pymysql://root@localhost:3306/pandas", 2789s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ________ ERROR at teardown of test_temporary_table[mysql_pymysql_conn] _________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def mysql_pymysql_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s pymysql = td.versioned_importorskip("pymysql") 2789s engine = sqlalchemy.create_engine( 2789s "mysql+pymysql://root@localhost:3306/pandas", 2789s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ____ ERROR at teardown of test_temporary_table[postgresql_psycopg2_engine] _____ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def postgresql_psycopg2_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s td.versioned_importorskip("psycopg2") 2789s engine = sqlalchemy.create_engine( 2789s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _____ ERROR at teardown of test_temporary_table[postgresql_psycopg2_conn] ______ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def postgresql_psycopg2_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s td.versioned_importorskip("psycopg2") 2789s engine = sqlalchemy.create_engine( 2789s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ________ ERROR at teardown of test_invalid_engine[mysql_pymysql_engine] ________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def mysql_pymysql_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s pymysql = td.versioned_importorskip("pymysql") 2789s engine = sqlalchemy.create_engine( 2789s "mysql+pymysql://root@localhost:3306/pandas", 2789s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _________ ERROR at teardown of test_invalid_engine[mysql_pymysql_conn] _________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def mysql_pymysql_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s pymysql = td.versioned_importorskip("pymysql") 2789s engine = sqlalchemy.create_engine( 2789s "mysql+pymysql://root@localhost:3306/pandas", 2789s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _____ ERROR at teardown of test_invalid_engine[postgresql_psycopg2_engine] _____ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def postgresql_psycopg2_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s td.versioned_importorskip("psycopg2") 2789s engine = sqlalchemy.create_engine( 2789s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ______ ERROR at teardown of test_invalid_engine[postgresql_psycopg2_conn] ______ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def postgresql_psycopg2_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s td.versioned_importorskip("psycopg2") 2789s engine = sqlalchemy.create_engine( 2789s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ____ ERROR at teardown of test_to_sql_with_sql_engine[mysql_pymysql_engine] ____ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def mysql_pymysql_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s pymysql = td.versioned_importorskip("pymysql") 2789s engine = sqlalchemy.create_engine( 2789s "mysql+pymysql://root@localhost:3306/pandas", 2789s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _____ ERROR at teardown of test_to_sql_with_sql_engine[mysql_pymysql_conn] _____ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def mysql_pymysql_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s pymysql = td.versioned_importorskip("pymysql") 2789s engine = sqlalchemy.create_engine( 2789s "mysql+pymysql://root@localhost:3306/pandas", 2789s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ ERROR at teardown of test_to_sql_with_sql_engine[postgresql_psycopg2_engine] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def postgresql_psycopg2_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s td.versioned_importorskip("psycopg2") 2789s engine = sqlalchemy.create_engine( 2789s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s __ ERROR at teardown of test_to_sql_with_sql_engine[postgresql_psycopg2_conn] __ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def postgresql_psycopg2_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s td.versioned_importorskip("psycopg2") 2789s engine = sqlalchemy.create_engine( 2789s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ______ ERROR at teardown of test_options_sqlalchemy[mysql_pymysql_engine] ______ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def mysql_pymysql_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s pymysql = td.versioned_importorskip("pymysql") 2789s engine = sqlalchemy.create_engine( 2789s "mysql+pymysql://root@localhost:3306/pandas", 2789s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _______ ERROR at teardown of test_options_sqlalchemy[mysql_pymysql_conn] _______ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def mysql_pymysql_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s pymysql = td.versioned_importorskip("pymysql") 2789s engine = sqlalchemy.create_engine( 2789s "mysql+pymysql://root@localhost:3306/pandas", 2789s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ___ ERROR at teardown of test_options_sqlalchemy[postgresql_psycopg2_engine] ___ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def postgresql_psycopg2_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s td.versioned_importorskip("psycopg2") 2789s engine = sqlalchemy.create_engine( 2789s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ____ ERROR at teardown of test_options_sqlalchemy[postgresql_psycopg2_conn] ____ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def postgresql_psycopg2_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s td.versioned_importorskip("psycopg2") 2789s engine = sqlalchemy.create_engine( 2789s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _________ ERROR at teardown of test_options_auto[mysql_pymysql_engine] _________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def mysql_pymysql_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s pymysql = td.versioned_importorskip("pymysql") 2789s engine = sqlalchemy.create_engine( 2789s "mysql+pymysql://root@localhost:3306/pandas", 2789s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s __________ ERROR at teardown of test_options_auto[mysql_pymysql_conn] __________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def mysql_pymysql_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s pymysql = td.versioned_importorskip("pymysql") 2789s engine = sqlalchemy.create_engine( 2789s "mysql+pymysql://root@localhost:3306/pandas", 2789s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ______ ERROR at teardown of test_options_auto[postgresql_psycopg2_engine] ______ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def postgresql_psycopg2_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s td.versioned_importorskip("psycopg2") 2789s engine = sqlalchemy.create_engine( 2789s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _______ ERROR at teardown of test_options_auto[postgresql_psycopg2_conn] _______ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def postgresql_psycopg2_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s td.versioned_importorskip("psycopg2") 2789s engine = sqlalchemy.create_engine( 2789s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql-mysql_pymysql_engine] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def mysql_pymysql_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s pymysql = td.versioned_importorskip("pymysql") 2789s engine = sqlalchemy.create_engine( 2789s "mysql+pymysql://root@localhost:3306/pandas", 2789s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql-mysql_pymysql_conn] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def mysql_pymysql_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s pymysql = td.versioned_importorskip("pymysql") 2789s engine = sqlalchemy.create_engine( 2789s "mysql+pymysql://root@localhost:3306/pandas", 2789s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql-postgresql_psycopg2_engine] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def postgresql_psycopg2_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s td.versioned_importorskip("psycopg2") 2789s engine = sqlalchemy.create_engine( 2789s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql-postgresql_psycopg2_conn] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def postgresql_psycopg2_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s td.versioned_importorskip("psycopg2") 2789s engine = sqlalchemy.create_engine( 2789s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-mysql_pymysql_engine] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def mysql_pymysql_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s pymysql = td.versioned_importorskip("pymysql") 2789s engine = sqlalchemy.create_engine( 2789s "mysql+pymysql://root@localhost:3306/pandas", 2789s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-mysql_pymysql_conn] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def mysql_pymysql_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s pymysql = td.versioned_importorskip("pymysql") 2789s engine = sqlalchemy.create_engine( 2789s "mysql+pymysql://root@localhost:3306/pandas", 2789s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-postgresql_psycopg2_engine] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def postgresql_psycopg2_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s td.versioned_importorskip("psycopg2") 2789s engine = sqlalchemy.create_engine( 2789s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-postgresql_psycopg2_conn] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def postgresql_psycopg2_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s td.versioned_importorskip("psycopg2") 2789s engine = sqlalchemy.create_engine( 2789s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-mysql_pymysql_engine] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def mysql_pymysql_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s pymysql = td.versioned_importorskip("pymysql") 2789s engine = sqlalchemy.create_engine( 2789s "mysql+pymysql://root@localhost:3306/pandas", 2789s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-mysql_pymysql_conn] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def mysql_pymysql_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s pymysql = td.versioned_importorskip("pymysql") 2789s engine = sqlalchemy.create_engine( 2789s "mysql+pymysql://root@localhost:3306/pandas", 2789s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-postgresql_psycopg2_engine] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def postgresql_psycopg2_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s td.versioned_importorskip("psycopg2") 2789s engine = sqlalchemy.create_engine( 2789s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-postgresql_psycopg2_conn] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def postgresql_psycopg2_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s td.versioned_importorskip("psycopg2") 2789s engine = sqlalchemy.create_engine( 2789s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-mysql_pymysql_engine] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def mysql_pymysql_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s pymysql = td.versioned_importorskip("pymysql") 2789s engine = sqlalchemy.create_engine( 2789s "mysql+pymysql://root@localhost:3306/pandas", 2789s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-mysql_pymysql_conn] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def mysql_pymysql_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s pymysql = td.versioned_importorskip("pymysql") 2789s engine = sqlalchemy.create_engine( 2789s "mysql+pymysql://root@localhost:3306/pandas", 2789s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-postgresql_psycopg2_engine] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def postgresql_psycopg2_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s td.versioned_importorskip("psycopg2") 2789s engine = sqlalchemy.create_engine( 2789s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-postgresql_psycopg2_conn] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def postgresql_psycopg2_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s td.versioned_importorskip("psycopg2") 2789s engine = sqlalchemy.create_engine( 2789s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_engine] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def mysql_pymysql_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s pymysql = td.versioned_importorskip("pymysql") 2789s engine = sqlalchemy.create_engine( 2789s "mysql+pymysql://root@localhost:3306/pandas", 2789s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_conn] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def mysql_pymysql_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s pymysql = td.versioned_importorskip("pymysql") 2789s engine = sqlalchemy.create_engine( 2789s "mysql+pymysql://root@localhost:3306/pandas", 2789s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_engine] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def postgresql_psycopg2_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s td.versioned_importorskip("psycopg2") 2789s engine = sqlalchemy.create_engine( 2789s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_conn] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def postgresql_psycopg2_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s td.versioned_importorskip("psycopg2") 2789s engine = sqlalchemy.create_engine( 2789s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_table-mysql_pymysql_engine] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def mysql_pymysql_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s pymysql = td.versioned_importorskip("pymysql") 2789s engine = sqlalchemy.create_engine( 2789s "mysql+pymysql://root@localhost:3306/pandas", 2789s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_table-mysql_pymysql_conn] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def mysql_pymysql_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s pymysql = td.versioned_importorskip("pymysql") 2789s engine = sqlalchemy.create_engine( 2789s "mysql+pymysql://root@localhost:3306/pandas", 2789s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_table-postgresql_psycopg2_engine] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def postgresql_psycopg2_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s td.versioned_importorskip("psycopg2") 2789s engine = sqlalchemy.create_engine( 2789s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_table-postgresql_psycopg2_conn] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def postgresql_psycopg2_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s td.versioned_importorskip("psycopg2") 2789s engine = sqlalchemy.create_engine( 2789s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_query-mysql_pymysql_engine] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def mysql_pymysql_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s pymysql = td.versioned_importorskip("pymysql") 2789s engine = sqlalchemy.create_engine( 2789s "mysql+pymysql://root@localhost:3306/pandas", 2789s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_query-mysql_pymysql_conn] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def mysql_pymysql_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s pymysql = td.versioned_importorskip("pymysql") 2789s engine = sqlalchemy.create_engine( 2789s "mysql+pymysql://root@localhost:3306/pandas", 2789s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_query-postgresql_psycopg2_engine] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def postgresql_psycopg2_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s td.versioned_importorskip("psycopg2") 2789s engine = sqlalchemy.create_engine( 2789s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_query-postgresql_psycopg2_conn] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def postgresql_psycopg2_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s td.versioned_importorskip("psycopg2") 2789s engine = sqlalchemy.create_engine( 2789s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ____ ERROR at teardown of test_chunksize_empty_dtypes[mysql_pymysql_engine] ____ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def mysql_pymysql_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s pymysql = td.versioned_importorskip("pymysql") 2789s engine = sqlalchemy.create_engine( 2789s "mysql+pymysql://root@localhost:3306/pandas", 2789s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _____ ERROR at teardown of test_chunksize_empty_dtypes[mysql_pymysql_conn] _____ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def mysql_pymysql_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s pymysql = td.versioned_importorskip("pymysql") 2789s engine = sqlalchemy.create_engine( 2789s "mysql+pymysql://root@localhost:3306/pandas", 2789s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ ERROR at teardown of test_chunksize_empty_dtypes[postgresql_psycopg2_engine] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def postgresql_psycopg2_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s td.versioned_importorskip("psycopg2") 2789s engine = sqlalchemy.create_engine( 2789s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s __ ERROR at teardown of test_chunksize_empty_dtypes[postgresql_psycopg2_conn] __ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def postgresql_psycopg2_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s td.versioned_importorskip("psycopg2") 2789s engine = sqlalchemy.create_engine( 2789s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ ERROR at teardown of test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_engine] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def mysql_pymysql_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s pymysql = td.versioned_importorskip("pymysql") 2789s engine = sqlalchemy.create_engine( 2789s "mysql+pymysql://root@localhost:3306/pandas", 2789s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ ERROR at teardown of test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_conn] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def mysql_pymysql_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s pymysql = td.versioned_importorskip("pymysql") 2789s engine = sqlalchemy.create_engine( 2789s "mysql+pymysql://root@localhost:3306/pandas", 2789s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ ERROR at teardown of test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_engine] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def postgresql_psycopg2_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s td.versioned_importorskip("psycopg2") 2789s engine = sqlalchemy.create_engine( 2789s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ ERROR at teardown of test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_conn] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def postgresql_psycopg2_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s td.versioned_importorskip("psycopg2") 2789s engine = sqlalchemy.create_engine( 2789s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ ERROR at teardown of test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_engine] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def mysql_pymysql_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s pymysql = td.versioned_importorskip("pymysql") 2789s engine = sqlalchemy.create_engine( 2789s "mysql+pymysql://root@localhost:3306/pandas", 2789s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ ERROR at teardown of test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_conn] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def mysql_pymysql_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s pymysql = td.versioned_importorskip("pymysql") 2789s engine = sqlalchemy.create_engine( 2789s "mysql+pymysql://root@localhost:3306/pandas", 2789s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ ERROR at teardown of test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_engine] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def postgresql_psycopg2_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s td.versioned_importorskip("psycopg2") 2789s engine = sqlalchemy.create_engine( 2789s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ ERROR at teardown of test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_conn] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def postgresql_psycopg2_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s td.versioned_importorskip("psycopg2") 2789s engine = sqlalchemy.create_engine( 2789s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-_NoDefault.no_default-mysql_pymysql_engine] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def mysql_pymysql_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s pymysql = td.versioned_importorskip("pymysql") 2789s engine = sqlalchemy.create_engine( 2789s "mysql+pymysql://root@localhost:3306/pandas", 2789s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-_NoDefault.no_default-mysql_pymysql_conn] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def mysql_pymysql_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s pymysql = td.versioned_importorskip("pymysql") 2789s engine = sqlalchemy.create_engine( 2789s "mysql+pymysql://root@localhost:3306/pandas", 2789s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-_NoDefault.no_default-postgresql_psycopg2_engine] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def postgresql_psycopg2_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s td.versioned_importorskip("psycopg2") 2789s engine = sqlalchemy.create_engine( 2789s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-_NoDefault.no_default-postgresql_psycopg2_conn] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def postgresql_psycopg2_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s td.versioned_importorskip("psycopg2") 2789s engine = sqlalchemy.create_engine( 2789s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_engine] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def mysql_pymysql_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s pymysql = td.versioned_importorskip("pymysql") 2789s engine = sqlalchemy.create_engine( 2789s "mysql+pymysql://root@localhost:3306/pandas", 2789s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_conn] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def mysql_pymysql_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s pymysql = td.versioned_importorskip("pymysql") 2789s engine = sqlalchemy.create_engine( 2789s "mysql+pymysql://root@localhost:3306/pandas", 2789s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_engine] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def postgresql_psycopg2_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s td.versioned_importorskip("psycopg2") 2789s engine = sqlalchemy.create_engine( 2789s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_conn] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def postgresql_psycopg2_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s td.versioned_importorskip("psycopg2") 2789s engine = sqlalchemy.create_engine( 2789s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ______________ ERROR at teardown of test_psycopg2_schema_support _______________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def postgresql_psycopg2_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s td.versioned_importorskip("psycopg2") 2789s engine = sqlalchemy.create_engine( 2789s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _______________ ERROR at teardown of test_self_join_date_columns _______________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s @pytest.fixture 2789s def postgresql_psycopg2_engine(): 2789s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2789s td.versioned_importorskip("psycopg2") 2789s engine = sqlalchemy.create_engine( 2789s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2789s poolclass=sqlalchemy.pool.NullPool, 2789s ) 2789s yield engine 2789s > for view in get_all_views(engine): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2789s return inspect(conn).get_view_names() 2789s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2789s ret = reg(subject) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2789s return Inspector._construct(Inspector._init_engine, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2789s init(self, bind) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2789s engine.connect().close() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s =================================== FAILURES =================================== 2789s _________________ test_dataframe_to_sql[mysql_pymysql_engine] __________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_dataframe_to_sql(conn, test_frame1, request): 2789s # GH 51086 if conn is sqlite_engine 2789s conn = request.getfixturevalue(conn) 2789s > test_frame1.to_sql(name="test", con=conn, if_exists="append", index=False) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:983: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2789s return func(*args, **kwargs) 2789s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2789s return sql.to_sql( 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2789s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s __________________ test_dataframe_to_sql[mysql_pymysql_conn] ___________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn' 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_dataframe_to_sql(conn, test_frame1, request): 2789s # GH 51086 if conn is sqlite_engine 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:982: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ______________ test_dataframe_to_sql[postgresql_psycopg2_engine] _______________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_dataframe_to_sql(conn, test_frame1, request): 2789s # GH 51086 if conn is sqlite_engine 2789s conn = request.getfixturevalue(conn) 2789s > test_frame1.to_sql(name="test", con=conn, if_exists="append", index=False) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:983: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2789s return func(*args, **kwargs) 2789s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2789s return sql.to_sql( 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2789s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _______________ test_dataframe_to_sql[postgresql_psycopg2_conn] ________________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn' 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_dataframe_to_sql(conn, test_frame1, request): 2789s # GH 51086 if conn is sqlite_engine 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:982: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ______________ test_dataframe_to_sql_empty[mysql_pymysql_engine] _______________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_dataframe_to_sql_empty(conn, test_frame1, request): 2789s if conn == "postgresql_adbc_conn": 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="postgres ADBC driver cannot insert index with null type", 2789s strict=True, 2789s ) 2789s ) 2789s # GH 51086 if conn is sqlite_engine 2789s conn = request.getfixturevalue(conn) 2789s empty_df = test_frame1.iloc[:0] 2789s > empty_df.to_sql(name="test", con=conn, if_exists="append", index=False) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:998: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2789s return func(*args, **kwargs) 2789s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2789s return sql.to_sql( 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2789s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _______________ test_dataframe_to_sql_empty[mysql_pymysql_conn] ________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn' 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_dataframe_to_sql_empty(conn, test_frame1, request): 2789s if conn == "postgresql_adbc_conn": 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="postgres ADBC driver cannot insert index with null type", 2789s strict=True, 2789s ) 2789s ) 2789s # GH 51086 if conn is sqlite_engine 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:996: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ___________ test_dataframe_to_sql_empty[postgresql_psycopg2_engine] ____________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_dataframe_to_sql_empty(conn, test_frame1, request): 2789s if conn == "postgresql_adbc_conn": 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="postgres ADBC driver cannot insert index with null type", 2789s strict=True, 2789s ) 2789s ) 2789s # GH 51086 if conn is sqlite_engine 2789s conn = request.getfixturevalue(conn) 2789s empty_df = test_frame1.iloc[:0] 2789s > empty_df.to_sql(name="test", con=conn, if_exists="append", index=False) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:998: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2789s return func(*args, **kwargs) 2789s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2789s return sql.to_sql( 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2789s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ____________ test_dataframe_to_sql_empty[postgresql_psycopg2_conn] _____________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn' 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_dataframe_to_sql_empty(conn, test_frame1, request): 2789s if conn == "postgresql_adbc_conn": 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="postgres ADBC driver cannot insert index with null type", 2789s strict=True, 2789s ) 2789s ) 2789s # GH 51086 if conn is sqlite_engine 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:996: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ____________________ test_to_sql[None-mysql_pymysql_engine] ____________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas), method = None 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize("method", [None, "multi"]) 2789s def test_to_sql(conn, method, test_frame1, request): 2789s if method == "multi" and "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="'method' not implemented for ADBC drivers", strict=True 2789s ) 2789s ) 2789s 2789s conn = request.getfixturevalue(conn) 2789s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1061: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _____________________ test_to_sql[None-mysql_pymysql_conn] _____________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn', method = None 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize("method", [None, "multi"]) 2789s def test_to_sql(conn, method, test_frame1, request): 2789s if method == "multi" and "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="'method' not implemented for ADBC drivers", strict=True 2789s ) 2789s ) 2789s 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1060: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _________________ test_to_sql[None-postgresql_psycopg2_engine] _________________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s method = None 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize("method", [None, "multi"]) 2789s def test_to_sql(conn, method, test_frame1, request): 2789s if method == "multi" and "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="'method' not implemented for ADBC drivers", strict=True 2789s ) 2789s ) 2789s 2789s conn = request.getfixturevalue(conn) 2789s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1061: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s __________________ test_to_sql[None-postgresql_psycopg2_conn] __________________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn', method = None 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize("method", [None, "multi"]) 2789s def test_to_sql(conn, method, test_frame1, request): 2789s if method == "multi" and "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="'method' not implemented for ADBC drivers", strict=True 2789s ) 2789s ) 2789s 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1060: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ___________________ test_to_sql[multi-mysql_pymysql_engine] ____________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas), method = 'multi' 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize("method", [None, "multi"]) 2789s def test_to_sql(conn, method, test_frame1, request): 2789s if method == "multi" and "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="'method' not implemented for ADBC drivers", strict=True 2789s ) 2789s ) 2789s 2789s conn = request.getfixturevalue(conn) 2789s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1061: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ____________________ test_to_sql[multi-mysql_pymysql_conn] _____________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn', method = 'multi' 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize("method", [None, "multi"]) 2789s def test_to_sql(conn, method, test_frame1, request): 2789s if method == "multi" and "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="'method' not implemented for ADBC drivers", strict=True 2789s ) 2789s ) 2789s 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1060: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ________________ test_to_sql[multi-postgresql_psycopg2_engine] _________________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s method = 'multi' 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize("method", [None, "multi"]) 2789s def test_to_sql(conn, method, test_frame1, request): 2789s if method == "multi" and "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="'method' not implemented for ADBC drivers", strict=True 2789s ) 2789s ) 2789s 2789s conn = request.getfixturevalue(conn) 2789s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1061: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _________________ test_to_sql[multi-postgresql_psycopg2_conn] __________________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn', method = 'multi' 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize("method", [None, "multi"]) 2789s def test_to_sql(conn, method, test_frame1, request): 2789s if method == "multi" and "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="'method' not implemented for ADBC drivers", strict=True 2789s ) 2789s ) 2789s 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1060: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ______________ test_to_sql_exist[replace-1-mysql_pymysql_engine] _______________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas), mode = 'replace' 2789s num_row_coef = 1 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 2789s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 2789s conn = request.getfixturevalue(conn) 2789s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1071: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _______________ test_to_sql_exist[replace-1-mysql_pymysql_conn] ________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn', mode = 'replace', num_row_coef = 1 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 2789s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1070: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ___________ test_to_sql_exist[replace-1-postgresql_psycopg2_engine] ____________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s mode = 'replace', num_row_coef = 1 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 2789s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 2789s conn = request.getfixturevalue(conn) 2789s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1071: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ____________ test_to_sql_exist[replace-1-postgresql_psycopg2_conn] _____________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn', mode = 'replace', num_row_coef = 1 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 2789s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1070: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _______________ test_to_sql_exist[append-2-mysql_pymysql_engine] _______________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas), mode = 'append' 2789s num_row_coef = 2 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 2789s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 2789s conn = request.getfixturevalue(conn) 2789s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1071: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ________________ test_to_sql_exist[append-2-mysql_pymysql_conn] ________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn', mode = 'append', num_row_coef = 2 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 2789s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1070: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ____________ test_to_sql_exist[append-2-postgresql_psycopg2_engine] ____________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s mode = 'append', num_row_coef = 2 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 2789s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 2789s conn = request.getfixturevalue(conn) 2789s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1071: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _____________ test_to_sql_exist[append-2-postgresql_psycopg2_conn] _____________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn', mode = 'append', num_row_coef = 2 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 2789s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1070: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _________________ test_to_sql_exist_fail[mysql_pymysql_engine] _________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_to_sql_exist_fail(conn, test_frame1, request): 2789s conn = request.getfixturevalue(conn) 2789s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1081: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s __________________ test_to_sql_exist_fail[mysql_pymysql_conn] __________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn' 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_to_sql_exist_fail(conn, test_frame1, request): 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1080: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ______________ test_to_sql_exist_fail[postgresql_psycopg2_engine] ______________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_to_sql_exist_fail(conn, test_frame1, request): 2789s conn = request.getfixturevalue(conn) 2789s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1081: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _______________ test_to_sql_exist_fail[postgresql_psycopg2_conn] _______________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn' 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_to_sql_exist_fail(conn, test_frame1, request): 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1080: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _______________ test_read_iris_query[mysql_pymysql_engine_iris] ________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_engine_iris' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_iris) 2789s def test_read_iris_query(conn, request): 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1092: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2789s create_and_load_iris(mysql_pymysql_engine, iris_path) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2789s with conn.begin() as con: 2789s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2789s return next(self.gen) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2789s with self.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ________________ test_read_iris_query[mysql_pymysql_conn_iris] _________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn_iris' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_iris) 2789s def test_read_iris_query(conn, request): 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1092: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2789s create_and_load_iris(mysql_pymysql_engine, iris_path) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2789s with conn.begin() as con: 2789s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2789s return next(self.gen) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2789s with self.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ____________ test_read_iris_query[postgresql_psycopg2_engine_iris] _____________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_engine_iris' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_iris) 2789s def test_read_iris_query(conn, request): 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1092: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2789s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2789s with conn.begin() as con: 2789s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2789s return next(self.gen) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2789s with self.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _____________ test_read_iris_query[postgresql_psycopg2_conn_iris] ______________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn_iris' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_iris) 2789s def test_read_iris_query(conn, request): 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1092: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2789s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2789s with conn.begin() as con: 2789s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2789s return next(self.gen) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2789s with self.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s __________ test_read_iris_query_chunksize[mysql_pymysql_engine_iris] ___________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_engine_iris' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_iris) 2789s def test_read_iris_query_chunksize(conn, request): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="'chunksize' not implemented for ADBC drivers", 2789s strict=True, 2789s ) 2789s ) 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1111: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2789s create_and_load_iris(mysql_pymysql_engine, iris_path) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2789s with conn.begin() as con: 2789s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2789s return next(self.gen) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2789s with self.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ___________ test_read_iris_query_chunksize[mysql_pymysql_conn_iris] ____________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn_iris' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_iris) 2789s def test_read_iris_query_chunksize(conn, request): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="'chunksize' not implemented for ADBC drivers", 2789s strict=True, 2789s ) 2789s ) 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1111: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2789s create_and_load_iris(mysql_pymysql_engine, iris_path) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2789s with conn.begin() as con: 2789s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2789s return next(self.gen) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2789s with self.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _______ test_read_iris_query_chunksize[postgresql_psycopg2_engine_iris] ________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_engine_iris' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_iris) 2789s def test_read_iris_query_chunksize(conn, request): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="'chunksize' not implemented for ADBC drivers", 2789s strict=True, 2789s ) 2789s ) 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1111: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2789s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2789s with conn.begin() as con: 2789s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2789s return next(self.gen) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2789s with self.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ________ test_read_iris_query_chunksize[postgresql_psycopg2_conn_iris] _________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn_iris' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_iris) 2789s def test_read_iris_query_chunksize(conn, request): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="'chunksize' not implemented for ADBC drivers", 2789s strict=True, 2789s ) 2789s ) 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1111: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2789s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2789s with conn.begin() as con: 2789s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2789s return next(self.gen) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2789s with self.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s __ test_read_iris_query_expression_with_parameter[mysql_pymysql_engine_iris] ___ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_engine_iris' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2789s def test_read_iris_query_expression_with_parameter(conn, request): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="'chunksize' not implemented for ADBC drivers", 2789s strict=True, 2789s ) 2789s ) 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1130: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2789s create_and_load_iris(mysql_pymysql_engine, iris_path) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2789s with conn.begin() as con: 2789s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2789s return next(self.gen) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2789s with self.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ___ test_read_iris_query_expression_with_parameter[mysql_pymysql_conn_iris] ____ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn_iris' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2789s def test_read_iris_query_expression_with_parameter(conn, request): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="'chunksize' not implemented for ADBC drivers", 2789s strict=True, 2789s ) 2789s ) 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1130: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2789s create_and_load_iris(mysql_pymysql_engine, iris_path) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2789s with conn.begin() as con: 2789s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2789s return next(self.gen) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2789s with self.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ test_read_iris_query_expression_with_parameter[postgresql_psycopg2_engine_iris] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_engine_iris' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2789s def test_read_iris_query_expression_with_parameter(conn, request): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="'chunksize' not implemented for ADBC drivers", 2789s strict=True, 2789s ) 2789s ) 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1130: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2789s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2789s with conn.begin() as con: 2789s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2789s return next(self.gen) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2789s with self.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ test_read_iris_query_expression_with_parameter[postgresql_psycopg2_conn_iris] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn_iris' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2789s def test_read_iris_query_expression_with_parameter(conn, request): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="'chunksize' not implemented for ADBC drivers", 2789s strict=True, 2789s ) 2789s ) 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1130: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2789s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2789s with conn.begin() as con: 2789s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2789s return next(self.gen) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2789s with self.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ____ test_read_iris_query_string_with_parameter[mysql_pymysql_engine_iris] _____ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_engine_iris' 2789s request = > 2789s 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=?'}} 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_iris) 2789s def test_read_iris_query_string_with_parameter(conn, request, sql_strings): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="'chunksize' not implemented for ADBC drivers", 2789s strict=True, 2789s ) 2789s ) 2789s 2789s for db, query in sql_strings["read_parameters"].items(): 2789s if db in conn: 2789s break 2789s else: 2789s raise KeyError(f"No part of {conn} found in sql_strings['read_parameters']") 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1164: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2789s create_and_load_iris(mysql_pymysql_engine, iris_path) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2789s with conn.begin() as con: 2789s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2789s return next(self.gen) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2789s with self.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _____ test_read_iris_query_string_with_parameter[mysql_pymysql_conn_iris] ______ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn_iris' 2789s request = > 2789s 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=?'}} 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_iris) 2789s def test_read_iris_query_string_with_parameter(conn, request, sql_strings): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="'chunksize' not implemented for ADBC drivers", 2789s strict=True, 2789s ) 2789s ) 2789s 2789s for db, query in sql_strings["read_parameters"].items(): 2789s if db in conn: 2789s break 2789s else: 2789s raise KeyError(f"No part of {conn} found in sql_strings['read_parameters']") 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1164: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2789s create_and_load_iris(mysql_pymysql_engine, iris_path) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2789s with conn.begin() as con: 2789s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2789s return next(self.gen) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2789s with self.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ test_read_iris_query_string_with_parameter[postgresql_psycopg2_engine_iris] __ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_engine_iris' 2789s request = > 2789s 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=?'}} 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_iris) 2789s def test_read_iris_query_string_with_parameter(conn, request, sql_strings): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="'chunksize' not implemented for ADBC drivers", 2789s strict=True, 2789s ) 2789s ) 2789s 2789s for db, query in sql_strings["read_parameters"].items(): 2789s if db in conn: 2789s break 2789s else: 2789s raise KeyError(f"No part of {conn} found in sql_strings['read_parameters']") 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1164: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2789s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2789s with conn.begin() as con: 2789s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2789s return next(self.gen) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2789s with self.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s __ test_read_iris_query_string_with_parameter[postgresql_psycopg2_conn_iris] ___ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn_iris' 2789s request = > 2789s 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=?'}} 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_iris) 2789s def test_read_iris_query_string_with_parameter(conn, request, sql_strings): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="'chunksize' not implemented for ADBC drivers", 2789s strict=True, 2789s ) 2789s ) 2789s 2789s for db, query in sql_strings["read_parameters"].items(): 2789s if db in conn: 2789s break 2789s else: 2789s raise KeyError(f"No part of {conn} found in sql_strings['read_parameters']") 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1164: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2789s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2789s with conn.begin() as con: 2789s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2789s return next(self.gen) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2789s with self.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _______________ test_read_iris_table[mysql_pymysql_engine_iris] ________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_engine_iris' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2789s def test_read_iris_table(conn, request): 2789s # GH 51015 if conn = sqlite_iris_str 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1172: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2789s create_and_load_iris(mysql_pymysql_engine, iris_path) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2789s with conn.begin() as con: 2789s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2789s return next(self.gen) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2789s with self.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ________________ test_read_iris_table[mysql_pymysql_conn_iris] _________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn_iris' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2789s def test_read_iris_table(conn, request): 2789s # GH 51015 if conn = sqlite_iris_str 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1172: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2789s create_and_load_iris(mysql_pymysql_engine, iris_path) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2789s with conn.begin() as con: 2789s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2789s return next(self.gen) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2789s with self.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ____________ test_read_iris_table[postgresql_psycopg2_engine_iris] _____________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_engine_iris' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2789s def test_read_iris_table(conn, request): 2789s # GH 51015 if conn = sqlite_iris_str 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1172: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2789s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2789s with conn.begin() as con: 2789s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2789s return next(self.gen) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2789s with self.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _____________ test_read_iris_table[postgresql_psycopg2_conn_iris] ______________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn_iris' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2789s def test_read_iris_table(conn, request): 2789s # GH 51015 if conn = sqlite_iris_str 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1172: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2789s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2789s with conn.begin() as con: 2789s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2789s return next(self.gen) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2789s with self.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s __________ test_read_iris_table_chunksize[mysql_pymysql_engine_iris] ___________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_engine_iris' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2789s def test_read_iris_table_chunksize(conn, request): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2789s ) 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1185: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2789s create_and_load_iris(mysql_pymysql_engine, iris_path) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2789s with conn.begin() as con: 2789s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2789s return next(self.gen) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2789s with self.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ___________ test_read_iris_table_chunksize[mysql_pymysql_conn_iris] ____________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn_iris' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2789s def test_read_iris_table_chunksize(conn, request): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2789s ) 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1185: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2789s create_and_load_iris(mysql_pymysql_engine, iris_path) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2789s with conn.begin() as con: 2789s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2789s return next(self.gen) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2789s with self.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _______ test_read_iris_table_chunksize[postgresql_psycopg2_engine_iris] ________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_engine_iris' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2789s def test_read_iris_table_chunksize(conn, request): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2789s ) 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1185: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2789s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2789s with conn.begin() as con: 2789s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2789s return next(self.gen) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2789s with self.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ________ test_read_iris_table_chunksize[postgresql_psycopg2_conn_iris] _________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn_iris' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2789s def test_read_iris_table_chunksize(conn, request): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2789s ) 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1185: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2789s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2789s with conn.begin() as con: 2789s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2789s return next(self.gen) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2789s with self.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s __________________ test_to_sql_callable[mysql_pymysql_engine] __________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2789s def test_to_sql_callable(conn, test_frame1, request): 2789s conn = request.getfixturevalue(conn) 2789s 2789s check = [] # used to double check function below is really being used 2789s 2789s def sample(pd_table, conn, keys, data_iter): 2789s check.append(1) 2789s data = [dict(zip(keys, row)) for row in data_iter] 2789s conn.execute(pd_table.table.insert(), data) 2789s 2789s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1203: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ___________________ test_to_sql_callable[mysql_pymysql_conn] ___________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn' 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2789s def test_to_sql_callable(conn, test_frame1, request): 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1194: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _______________ test_to_sql_callable[postgresql_psycopg2_engine] _______________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2789s def test_to_sql_callable(conn, test_frame1, request): 2789s conn = request.getfixturevalue(conn) 2789s 2789s check = [] # used to double check function below is really being used 2789s 2789s def sample(pd_table, conn, keys, data_iter): 2789s check.append(1) 2789s data = [dict(zip(keys, row)) for row in data_iter] 2789s conn.execute(pd_table.table.insert(), data) 2789s 2789s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1203: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ________________ test_to_sql_callable[postgresql_psycopg2_conn] ________________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn' 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2789s def test_to_sql_callable(conn, test_frame1, request): 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1194: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ___________ test_default_type_conversion[mysql_pymysql_engine_types] ___________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_engine_types' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s def test_default_type_conversion(conn, request): 2789s conn_name = conn 2789s if conn_name == "sqlite_buildin_types": 2789s request.applymarker( 2789s pytest.mark.xfail( 2789s reason="sqlite_buildin connection does not implement read_sql_table" 2789s ) 2789s ) 2789s 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1220: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2789s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ____________ test_default_type_conversion[mysql_pymysql_conn_types] ____________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn_types' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s def test_default_type_conversion(conn, request): 2789s conn_name = conn 2789s if conn_name == "sqlite_buildin_types": 2789s request.applymarker( 2789s pytest.mark.xfail( 2789s reason="sqlite_buildin connection does not implement read_sql_table" 2789s ) 2789s ) 2789s 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1220: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2789s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ________ test_default_type_conversion[postgresql_psycopg2_engine_types] ________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_engine_types' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s def test_default_type_conversion(conn, request): 2789s conn_name = conn 2789s if conn_name == "sqlite_buildin_types": 2789s request.applymarker( 2789s pytest.mark.xfail( 2789s reason="sqlite_buildin connection does not implement read_sql_table" 2789s ) 2789s ) 2789s 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1220: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2789s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _________ test_default_type_conversion[postgresql_psycopg2_conn_types] _________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn_types' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s def test_default_type_conversion(conn, request): 2789s conn_name = conn 2789s if conn_name == "sqlite_buildin_types": 2789s request.applymarker( 2789s pytest.mark.xfail( 2789s reason="sqlite_buildin connection does not implement read_sql_table" 2789s ) 2789s ) 2789s 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1220: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2789s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s __________________ test_read_procedure[mysql_pymysql_engine] ___________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", mysql_connectable) 2789s def test_read_procedure(conn, request): 2789s conn = request.getfixturevalue(conn) 2789s 2789s # GH 7324 2789s # Although it is more an api test, it is added to the 2789s # mysql tests as sqlite does not have stored procedures 2789s from sqlalchemy import text 2789s from sqlalchemy.engine import Engine 2789s 2789s df = DataFrame({"a": [1, 2, 3], "b": [0.1, 0.2, 0.3]}) 2789s > df.to_sql(name="test_frame", con=conn, index=False) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1253: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2789s return func(*args, **kwargs) 2789s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2789s return sql.to_sql( 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2789s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ___________________ test_read_procedure[mysql_pymysql_conn] ____________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", mysql_connectable) 2789s def test_read_procedure(conn, request): 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1244: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ____ test_copy_from_callable_insertion_method[2-postgresql_psycopg2_engine] ____ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s expected_count = 2 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", postgresql_connectable) 2789s @pytest.mark.parametrize("expected_count", [2, "Success!"]) 2789s def test_copy_from_callable_insertion_method(conn, expected_count, request): 2789s # GH 8953 2789s # Example in io.rst found under _io.sql.method 2789s # not available in sqlite, mysql 2789s def psql_insert_copy(table, conn, keys, data_iter): 2789s # gets a DBAPI connection that can provide a cursor 2789s dbapi_conn = conn.connection 2789s with dbapi_conn.cursor() as cur: 2789s s_buf = StringIO() 2789s writer = csv.writer(s_buf) 2789s writer.writerows(data_iter) 2789s s_buf.seek(0) 2789s 2789s columns = ", ".join([f'"{k}"' for k in keys]) 2789s if table.schema: 2789s table_name = f"{table.schema}.{table.name}" 2789s else: 2789s table_name = table.name 2789s 2789s sql_query = f"COPY {table_name} ({columns}) FROM STDIN WITH CSV" 2789s cur.copy_expert(sql=sql_query, file=s_buf) 2789s return expected_count 2789s 2789s conn = request.getfixturevalue(conn) 2789s expected = DataFrame({"col1": [1, 2], "col2": [0.1, 0.2], "col3": ["a", "n"]}) 2789s > result_count = expected.to_sql( 2789s name="test_frame", con=conn, index=False, method=psql_insert_copy 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1306: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2789s return func(*args, **kwargs) 2789s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2789s return sql.to_sql( 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2789s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _____ test_copy_from_callable_insertion_method[2-postgresql_psycopg2_conn] _____ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn', expected_count = 2 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", postgresql_connectable) 2789s @pytest.mark.parametrize("expected_count", [2, "Success!"]) 2789s def test_copy_from_callable_insertion_method(conn, expected_count, request): 2789s # GH 8953 2789s # Example in io.rst found under _io.sql.method 2789s # not available in sqlite, mysql 2789s def psql_insert_copy(table, conn, keys, data_iter): 2789s # gets a DBAPI connection that can provide a cursor 2789s dbapi_conn = conn.connection 2789s with dbapi_conn.cursor() as cur: 2789s s_buf = StringIO() 2789s writer = csv.writer(s_buf) 2789s writer.writerows(data_iter) 2789s s_buf.seek(0) 2789s 2789s columns = ", ".join([f'"{k}"' for k in keys]) 2789s if table.schema: 2789s table_name = f"{table.schema}.{table.name}" 2789s else: 2789s table_name = table.name 2789s 2789s sql_query = f"COPY {table_name} ({columns}) FROM STDIN WITH CSV" 2789s cur.copy_expert(sql=sql_query, file=s_buf) 2789s return expected_count 2789s 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1304: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_engine] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s expected_count = 'Success!' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", postgresql_connectable) 2789s @pytest.mark.parametrize("expected_count", [2, "Success!"]) 2789s def test_copy_from_callable_insertion_method(conn, expected_count, request): 2789s # GH 8953 2789s # Example in io.rst found under _io.sql.method 2789s # not available in sqlite, mysql 2789s def psql_insert_copy(table, conn, keys, data_iter): 2789s # gets a DBAPI connection that can provide a cursor 2789s dbapi_conn = conn.connection 2789s with dbapi_conn.cursor() as cur: 2789s s_buf = StringIO() 2789s writer = csv.writer(s_buf) 2789s writer.writerows(data_iter) 2789s s_buf.seek(0) 2789s 2789s columns = ", ".join([f'"{k}"' for k in keys]) 2789s if table.schema: 2789s table_name = f"{table.schema}.{table.name}" 2789s else: 2789s table_name = table.name 2789s 2789s sql_query = f"COPY {table_name} ({columns}) FROM STDIN WITH CSV" 2789s cur.copy_expert(sql=sql_query, file=s_buf) 2789s return expected_count 2789s 2789s conn = request.getfixturevalue(conn) 2789s expected = DataFrame({"col1": [1, 2], "col2": [0.1, 0.2], "col3": ["a", "n"]}) 2789s > result_count = expected.to_sql( 2789s name="test_frame", con=conn, index=False, method=psql_insert_copy 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1306: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2789s return func(*args, **kwargs) 2789s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2789s return sql.to_sql( 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2789s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_conn] __ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn', expected_count = 'Success!' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", postgresql_connectable) 2789s @pytest.mark.parametrize("expected_count", [2, "Success!"]) 2789s def test_copy_from_callable_insertion_method(conn, expected_count, request): 2789s # GH 8953 2789s # Example in io.rst found under _io.sql.method 2789s # not available in sqlite, mysql 2789s def psql_insert_copy(table, conn, keys, data_iter): 2789s # gets a DBAPI connection that can provide a cursor 2789s dbapi_conn = conn.connection 2789s with dbapi_conn.cursor() as cur: 2789s s_buf = StringIO() 2789s writer = csv.writer(s_buf) 2789s writer.writerows(data_iter) 2789s s_buf.seek(0) 2789s 2789s columns = ", ".join([f'"{k}"' for k in keys]) 2789s if table.schema: 2789s table_name = f"{table.schema}.{table.name}" 2789s else: 2789s table_name = table.name 2789s 2789s sql_query = f"COPY {table_name} ({columns}) FROM STDIN WITH CSV" 2789s cur.copy_expert(sql=sql_query, file=s_buf) 2789s return expected_count 2789s 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1304: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ___ test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_engine] ___ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", postgresql_connectable) 2789s def test_insertion_method_on_conflict_do_nothing(conn, request): 2789s # GH 15988: Example in to_sql docstring 2789s conn = request.getfixturevalue(conn) 2789s 2789s from sqlalchemy.dialects.postgresql import insert 2789s from sqlalchemy.engine import Engine 2789s from sqlalchemy.sql import text 2789s 2789s def insert_on_conflict(table, conn, keys, data_iter): 2789s data = [dict(zip(keys, row)) for row in data_iter] 2789s stmt = ( 2789s insert(table.table) 2789s .values(data) 2789s .on_conflict_do_nothing(index_elements=["a"]) 2789s ) 2789s result = conn.execute(stmt) 2789s return result.rowcount 2789s 2789s create_sql = text( 2789s """ 2789s CREATE TABLE test_insert_conflict ( 2789s a integer PRIMARY KEY, 2789s b numeric, 2789s c text 2789s ); 2789s """ 2789s ) 2789s if isinstance(conn, Engine): 2789s > with conn.connect() as con: 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1347: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ____ test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_conn] ____ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", postgresql_connectable) 2789s def test_insertion_method_on_conflict_do_nothing(conn, request): 2789s # GH 15988: Example in to_sql docstring 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1321: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ___________ test_to_sql_on_public_schema[postgresql_psycopg2_engine] ___________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_to_sql_on_public_schema(conn, request): 2789s if "sqlite" in conn or "mysql" in conn: 2789s request.applymarker( 2789s pytest.mark.xfail( 2789s reason="test for public schema only specific to postgresql" 2789s ) 2789s ) 2789s 2789s conn = request.getfixturevalue(conn) 2789s 2789s test_data = DataFrame([[1, 2.1, "a"], [2, 3.1, "b"]], columns=list("abc")) 2789s > test_data.to_sql( 2789s name="test_public_schema", 2789s con=conn, 2789s if_exists="append", 2789s index=False, 2789s schema="public", 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1388: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2789s return func(*args, **kwargs) 2789s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2789s return sql.to_sql( 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2789s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ____________ test_to_sql_on_public_schema[postgresql_psycopg2_conn] ____________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_to_sql_on_public_schema(conn, request): 2789s if "sqlite" in conn or "mysql" in conn: 2789s request.applymarker( 2789s pytest.mark.xfail( 2789s reason="test for public schema only specific to postgresql" 2789s ) 2789s ) 2789s 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1385: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ________ test_insertion_method_on_conflict_update[mysql_pymysql_engine] ________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", mysql_connectable) 2789s def test_insertion_method_on_conflict_update(conn, request): 2789s # GH 14553: Example in to_sql docstring 2789s conn = request.getfixturevalue(conn) 2789s 2789s from sqlalchemy.dialects.mysql import insert 2789s from sqlalchemy.engine import Engine 2789s from sqlalchemy.sql import text 2789s 2789s def insert_on_conflict(table, conn, keys, data_iter): 2789s data = [dict(zip(keys, row)) for row in data_iter] 2789s stmt = insert(table.table).values(data) 2789s stmt = stmt.on_duplicate_key_update(b=stmt.inserted.b, c=stmt.inserted.c) 2789s result = conn.execute(stmt) 2789s return result.rowcount 2789s 2789s create_sql = text( 2789s """ 2789s CREATE TABLE test_insert_conflict ( 2789s a INT PRIMARY KEY, 2789s b FLOAT, 2789s c VARCHAR(10) 2789s ); 2789s """ 2789s ) 2789s if isinstance(conn, Engine): 2789s > with conn.connect() as con: 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1426: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _________ test_insertion_method_on_conflict_update[mysql_pymysql_conn] _________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", mysql_connectable) 2789s def test_insertion_method_on_conflict_update(conn, request): 2789s # GH 14553: Example in to_sql docstring 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1403: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _____________ test_read_view_postgres[postgresql_psycopg2_engine] ______________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", postgresql_connectable) 2789s def test_read_view_postgres(conn, request): 2789s # GH 52969 2789s conn = request.getfixturevalue(conn) 2789s 2789s from sqlalchemy.engine import Engine 2789s from sqlalchemy.sql import text 2789s 2789s table_name = f"group_{uuid.uuid4().hex}" 2789s view_name = f"group_view_{uuid.uuid4().hex}" 2789s 2789s sql_stmt = text( 2789s f""" 2789s CREATE TABLE {table_name} ( 2789s group_id INTEGER, 2789s name TEXT 2789s ); 2789s INSERT INTO {table_name} VALUES 2789s (1, 'name'); 2789s CREATE VIEW {view_name} 2789s AS 2789s SELECT * FROM {table_name}; 2789s """ 2789s ) 2789s if isinstance(conn, Engine): 2789s > with conn.connect() as con: 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1478: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ______________ test_read_view_postgres[postgresql_psycopg2_conn] _______________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", postgresql_connectable) 2789s def test_read_view_postgres(conn, request): 2789s # GH 52969 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1456: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ___________ test_read_sql_iris_parameter[mysql_pymysql_engine_iris] ____________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_engine_iris' 2789s request = > 2789s 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=?'}} 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_iris) 2789s def test_read_sql_iris_parameter(conn, request, sql_strings): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="'params' not implemented for ADBC drivers", 2789s strict=True, 2789s ) 2789s ) 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1555: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2789s create_and_load_iris(mysql_pymysql_engine, iris_path) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2789s with conn.begin() as con: 2789s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2789s return next(self.gen) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2789s with self.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ____________ test_read_sql_iris_parameter[mysql_pymysql_conn_iris] _____________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn_iris' 2789s request = > 2789s 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=?'}} 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_iris) 2789s def test_read_sql_iris_parameter(conn, request, sql_strings): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="'params' not implemented for ADBC drivers", 2789s strict=True, 2789s ) 2789s ) 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1555: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2789s create_and_load_iris(mysql_pymysql_engine, iris_path) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2789s with conn.begin() as con: 2789s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2789s return next(self.gen) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2789s with self.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ________ test_read_sql_iris_parameter[postgresql_psycopg2_engine_iris] _________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_engine_iris' 2789s request = > 2789s 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=?'}} 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_iris) 2789s def test_read_sql_iris_parameter(conn, request, sql_strings): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="'params' not implemented for ADBC drivers", 2789s strict=True, 2789s ) 2789s ) 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1555: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2789s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2789s with conn.begin() as con: 2789s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2789s return next(self.gen) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2789s with self.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _________ test_read_sql_iris_parameter[postgresql_psycopg2_conn_iris] __________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn_iris' 2789s request = > 2789s 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=?'}} 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_iris) 2789s def test_read_sql_iris_parameter(conn, request, sql_strings): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="'params' not implemented for ADBC drivers", 2789s strict=True, 2789s ) 2789s ) 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1555: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2789s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2789s with conn.begin() as con: 2789s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2789s return next(self.gen) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2789s with self.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ________ test_read_sql_iris_named_parameter[mysql_pymysql_engine_iris] _________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_engine_iris' 2789s request = > 2789s 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=?'}} 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_iris) 2789s def test_read_sql_iris_named_parameter(conn, request, sql_strings): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="'params' not implemented for ADBC drivers", 2789s strict=True, 2789s ) 2789s ) 2789s 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1575: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2789s create_and_load_iris(mysql_pymysql_engine, iris_path) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2789s with conn.begin() as con: 2789s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2789s return next(self.gen) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2789s with self.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _________ test_read_sql_iris_named_parameter[mysql_pymysql_conn_iris] __________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn_iris' 2789s request = > 2789s 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=?'}} 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_iris) 2789s def test_read_sql_iris_named_parameter(conn, request, sql_strings): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="'params' not implemented for ADBC drivers", 2789s strict=True, 2789s ) 2789s ) 2789s 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1575: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2789s create_and_load_iris(mysql_pymysql_engine, iris_path) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2789s with conn.begin() as con: 2789s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2789s return next(self.gen) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2789s with self.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _____ test_read_sql_iris_named_parameter[postgresql_psycopg2_engine_iris] ______ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_engine_iris' 2789s request = > 2789s 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=?'}} 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_iris) 2789s def test_read_sql_iris_named_parameter(conn, request, sql_strings): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="'params' not implemented for ADBC drivers", 2789s strict=True, 2789s ) 2789s ) 2789s 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1575: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2789s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2789s with conn.begin() as con: 2789s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2789s return next(self.gen) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2789s with self.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ______ test_read_sql_iris_named_parameter[postgresql_psycopg2_conn_iris] _______ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn_iris' 2789s request = > 2789s 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=?'}} 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_iris) 2789s def test_read_sql_iris_named_parameter(conn, request, sql_strings): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="'params' not implemented for ADBC drivers", 2789s strict=True, 2789s ) 2789s ) 2789s 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1575: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2789s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2789s with conn.begin() as con: 2789s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2789s return next(self.gen) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2789s with self.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ______________ test_api_read_sql_view[mysql_pymysql_engine_iris] _______________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_engine_iris' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_iris) 2789s def test_api_read_sql_view(conn, request): 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1605: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2789s create_and_load_iris(mysql_pymysql_engine, iris_path) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2789s with conn.begin() as con: 2789s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2789s return next(self.gen) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2789s with self.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _______________ test_api_read_sql_view[mysql_pymysql_conn_iris] ________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn_iris' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_iris) 2789s def test_api_read_sql_view(conn, request): 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1605: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2789s create_and_load_iris(mysql_pymysql_engine, iris_path) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2789s with conn.begin() as con: 2789s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2789s return next(self.gen) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2789s with self.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ___________ test_api_read_sql_view[postgresql_psycopg2_engine_iris] ____________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_engine_iris' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_iris) 2789s def test_api_read_sql_view(conn, request): 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1605: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2789s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2789s with conn.begin() as con: 2789s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2789s return next(self.gen) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2789s with self.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ____________ test_api_read_sql_view[postgresql_psycopg2_conn_iris] _____________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn_iris' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_iris) 2789s def test_api_read_sql_view(conn, request): 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1605: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2789s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2789s with conn.begin() as con: 2789s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2789s return next(self.gen) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2789s with self.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ____ test_api_read_sql_with_chunksize_no_result[mysql_pymysql_engine_iris] _____ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_engine_iris' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_iris) 2789s def test_api_read_sql_with_chunksize_no_result(conn, request): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2789s ) 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1616: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2789s create_and_load_iris(mysql_pymysql_engine, iris_path) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2789s with conn.begin() as con: 2789s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2789s return next(self.gen) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2789s with self.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _____ test_api_read_sql_with_chunksize_no_result[mysql_pymysql_conn_iris] ______ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn_iris' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_iris) 2789s def test_api_read_sql_with_chunksize_no_result(conn, request): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2789s ) 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1616: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2789s create_and_load_iris(mysql_pymysql_engine, iris_path) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2789s with conn.begin() as con: 2789s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2789s return next(self.gen) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2789s with self.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_engine_iris] __ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_engine_iris' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_iris) 2789s def test_api_read_sql_with_chunksize_no_result(conn, request): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2789s ) 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1616: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2789s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2789s with conn.begin() as con: 2789s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2789s return next(self.gen) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2789s with self.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s __ test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_conn_iris] ___ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn_iris' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_iris) 2789s def test_api_read_sql_with_chunksize_no_result(conn, request): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2789s ) 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1616: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2789s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2789s with conn.begin() as con: 2789s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2789s return next(self.gen) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2789s with self.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ____________________ test_api_to_sql[mysql_pymysql_engine] _____________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2789s request = > 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_to_sql(conn, request, test_frame1): 2789s conn = request.getfixturevalue(conn) 2789s > if sql.has_table("test_frame1", conn): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1626: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2789s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _____________________ test_api_to_sql[mysql_pymysql_conn] ______________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn' 2789s request = > 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_to_sql(conn, request, test_frame1): 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1625: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _________________ test_api_to_sql[postgresql_psycopg2_engine] __________________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s request = > 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_to_sql(conn, request, test_frame1): 2789s conn = request.getfixturevalue(conn) 2789s > if sql.has_table("test_frame1", conn): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1626: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2789s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s __________________ test_api_to_sql[postgresql_psycopg2_conn] ___________________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn' 2789s request = > 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_to_sql(conn, request, test_frame1): 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1625: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s __________________ test_api_to_sql_fail[mysql_pymysql_engine] __________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2789s request = > 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_to_sql_fail(conn, request, test_frame1): 2789s conn = request.getfixturevalue(conn) 2789s > if sql.has_table("test_frame2", conn): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1637: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2789s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ___________________ test_api_to_sql_fail[mysql_pymysql_conn] ___________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn' 2789s request = > 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_to_sql_fail(conn, request, test_frame1): 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1636: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _______________ test_api_to_sql_fail[postgresql_psycopg2_engine] _______________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s request = > 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_to_sql_fail(conn, request, test_frame1): 2789s conn = request.getfixturevalue(conn) 2789s > if sql.has_table("test_frame2", conn): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1637: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2789s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ________________ test_api_to_sql_fail[postgresql_psycopg2_conn] ________________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn' 2789s request = > 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_to_sql_fail(conn, request, test_frame1): 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1636: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ________________ test_api_to_sql_replace[mysql_pymysql_engine] _________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2789s request = > 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_to_sql_replace(conn, request, test_frame1): 2789s conn = request.getfixturevalue(conn) 2789s > if sql.has_table("test_frame3", conn): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1652: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2789s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _________________ test_api_to_sql_replace[mysql_pymysql_conn] __________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn' 2789s request = > 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_to_sql_replace(conn, request, test_frame1): 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1651: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _____________ test_api_to_sql_replace[postgresql_psycopg2_engine] ______________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s request = > 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_to_sql_replace(conn, request, test_frame1): 2789s conn = request.getfixturevalue(conn) 2789s > if sql.has_table("test_frame3", conn): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1652: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2789s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ______________ test_api_to_sql_replace[postgresql_psycopg2_conn] _______________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn' 2789s request = > 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_to_sql_replace(conn, request, test_frame1): 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1651: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _________________ test_api_to_sql_append[mysql_pymysql_engine] _________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2789s request = > 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_to_sql_append(conn, request, test_frame1): 2789s conn = request.getfixturevalue(conn) 2789s > if sql.has_table("test_frame4", conn): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1670: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2789s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s __________________ test_api_to_sql_append[mysql_pymysql_conn] __________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn' 2789s request = > 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_to_sql_append(conn, request, test_frame1): 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1669: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ______________ test_api_to_sql_append[postgresql_psycopg2_engine] ______________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s request = > 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_to_sql_append(conn, request, test_frame1): 2789s conn = request.getfixturevalue(conn) 2789s > if sql.has_table("test_frame4", conn): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1670: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2789s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _______________ test_api_to_sql_append[postgresql_psycopg2_conn] _______________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn' 2789s request = > 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_to_sql_append(conn, request, test_frame1): 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1669: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ______________ test_api_to_sql_type_mapping[mysql_pymysql_engine] ______________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2789s request = > 2789s test_frame3 = index A B 2789s 0 2000-01-03 00:00:00 2147483647 -1.987670 2789s 1 2000-01-04 00:00:00 -29 -0.041232 2789s 2 2000-01-05 00:00:00 20000 0.731168 2789s 3 2000-01-06 00:00:00 -290867 1.567621 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_to_sql_type_mapping(conn, request, test_frame3): 2789s conn = request.getfixturevalue(conn) 2789s > if sql.has_table("test_frame5", conn): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1689: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2789s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _______________ test_api_to_sql_type_mapping[mysql_pymysql_conn] _______________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn' 2789s request = > 2789s test_frame3 = index A B 2789s 0 2000-01-03 00:00:00 2147483647 -1.987670 2789s 1 2000-01-04 00:00:00 -29 -0.041232 2789s 2 2000-01-05 00:00:00 20000 0.731168 2789s 3 2000-01-06 00:00:00 -290867 1.567621 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_to_sql_type_mapping(conn, request, test_frame3): 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1688: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ___________ test_api_to_sql_type_mapping[postgresql_psycopg2_engine] ___________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s request = > 2789s test_frame3 = index A B 2789s 0 2000-01-03 00:00:00 2147483647 -1.987670 2789s 1 2000-01-04 00:00:00 -29 -0.041232 2789s 2 2000-01-05 00:00:00 20000 0.731168 2789s 3 2000-01-06 00:00:00 -290867 1.567621 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_to_sql_type_mapping(conn, request, test_frame3): 2789s conn = request.getfixturevalue(conn) 2789s > if sql.has_table("test_frame5", conn): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1689: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2789s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ____________ test_api_to_sql_type_mapping[postgresql_psycopg2_conn] ____________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn' 2789s request = > 2789s test_frame3 = index A B 2789s 0 2000-01-03 00:00:00 2147483647 -1.987670 2789s 1 2000-01-04 00:00:00 -29 -0.041232 2789s 2 2000-01-05 00:00:00 20000 0.731168 2789s 3 2000-01-06 00:00:00 -290867 1.567621 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_to_sql_type_mapping(conn, request, test_frame3): 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1688: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _________________ test_api_to_sql_series[mysql_pymysql_engine] _________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_to_sql_series(conn, request): 2789s conn = request.getfixturevalue(conn) 2789s > if sql.has_table("test_series", conn): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1702: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2789s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s __________________ test_api_to_sql_series[mysql_pymysql_conn] __________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_to_sql_series(conn, request): 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1701: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ______________ test_api_to_sql_series[postgresql_psycopg2_engine] ______________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_to_sql_series(conn, request): 2789s conn = request.getfixturevalue(conn) 2789s > if sql.has_table("test_series", conn): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1702: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2789s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _______________ test_api_to_sql_series[postgresql_psycopg2_conn] _______________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_to_sql_series(conn, request): 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1701: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ___________________ test_api_roundtrip[mysql_pymysql_engine] ___________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2789s request = > 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_roundtrip(conn, request, test_frame1): 2789s conn_name = conn 2789s conn = request.getfixturevalue(conn) 2789s > if sql.has_table("test_frame_roundtrip", conn): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1716: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2789s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ____________________ test_api_roundtrip[mysql_pymysql_conn] ____________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn' 2789s request = > 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_roundtrip(conn, request, test_frame1): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1715: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ________________ test_api_roundtrip[postgresql_psycopg2_engine] ________________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s request = > 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_roundtrip(conn, request, test_frame1): 2789s conn_name = conn 2789s conn = request.getfixturevalue(conn) 2789s > if sql.has_table("test_frame_roundtrip", conn): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1716: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2789s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _________________ test_api_roundtrip[postgresql_psycopg2_conn] _________________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn' 2789s request = > 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_roundtrip(conn, request, test_frame1): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1715: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ______________ test_api_roundtrip_chunksize[mysql_pymysql_engine] ______________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2789s request = > 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_roundtrip_chunksize(conn, request, test_frame1): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2789s ) 2789s conn = request.getfixturevalue(conn) 2789s > if sql.has_table("test_frame_roundtrip", conn): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1740: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2789s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _______________ test_api_roundtrip_chunksize[mysql_pymysql_conn] _______________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn' 2789s request = > 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_roundtrip_chunksize(conn, request, test_frame1): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2789s ) 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1739: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ___________ test_api_roundtrip_chunksize[postgresql_psycopg2_engine] ___________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s request = > 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_roundtrip_chunksize(conn, request, test_frame1): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2789s ) 2789s conn = request.getfixturevalue(conn) 2789s > if sql.has_table("test_frame_roundtrip", conn): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1740: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2789s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ____________ test_api_roundtrip_chunksize[postgresql_psycopg2_conn] ____________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn' 2789s request = > 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_roundtrip_chunksize(conn, request, test_frame1): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2789s ) 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1739: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _______________ test_api_execute_sql[mysql_pymysql_engine_iris] ________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_engine_iris' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_iris) 2789s def test_api_execute_sql(conn, request): 2789s # drop_sql = "DROP TABLE IF EXISTS test" # should already be done 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1758: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2789s create_and_load_iris(mysql_pymysql_engine, iris_path) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2789s with conn.begin() as con: 2789s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2789s return next(self.gen) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2789s with self.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ________________ test_api_execute_sql[mysql_pymysql_conn_iris] _________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn_iris' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_iris) 2789s def test_api_execute_sql(conn, request): 2789s # drop_sql = "DROP TABLE IF EXISTS test" # should already be done 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1758: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2789s create_and_load_iris(mysql_pymysql_engine, iris_path) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2789s with conn.begin() as con: 2789s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2789s return next(self.gen) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2789s with self.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ____________ test_api_execute_sql[postgresql_psycopg2_engine_iris] _____________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_engine_iris' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_iris) 2789s def test_api_execute_sql(conn, request): 2789s # drop_sql = "DROP TABLE IF EXISTS test" # should already be done 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1758: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2789s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2789s with conn.begin() as con: 2789s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2789s return next(self.gen) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2789s with self.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _____________ test_api_execute_sql[postgresql_psycopg2_conn_iris] ______________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn_iris' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_iris) 2789s def test_api_execute_sql(conn, request): 2789s # drop_sql = "DROP TABLE IF EXISTS test" # should already be done 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1758: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2789s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2789s with conn.begin() as con: 2789s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2789s return next(self.gen) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2789s with self.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ______________ test_api_date_parsing[mysql_pymysql_engine_types] _______________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_engine_types' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s def test_api_date_parsing(conn, request): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1769: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2789s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _______________ test_api_date_parsing[mysql_pymysql_conn_types] ________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn_types' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s def test_api_date_parsing(conn, request): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1769: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2789s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ___________ test_api_date_parsing[postgresql_psycopg2_engine_types] ____________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_engine_types' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s def test_api_date_parsing(conn, request): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1769: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2789s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ____________ test_api_date_parsing[postgresql_psycopg2_conn_types] _____________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn_types' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s def test_api_date_parsing(conn, request): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1769: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2789s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-mysql_pymysql_engine_types] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_engine_types' 2789s request = > 2789s read_sql = , text = 'SELECT * FROM types' 2789s mode = ('sqlalchemy', 'fallback'), error = 'ignore' 2789s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2789s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2789s 1 first 2000-01-04 00:00:00 ... NaN NaN 2789s 2789s [2 rows x 9 columns] 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2789s @pytest.mark.parametrize( 2789s "read_sql, text, mode", 2789s [ 2789s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2789s (sql.read_sql, "types", ("sqlalchemy")), 2789s ( 2789s sql.read_sql_query, 2789s "SELECT * FROM types", 2789s ("sqlalchemy", "fallback"), 2789s ), 2789s (sql.read_sql_table, "types", ("sqlalchemy")), 2789s ], 2789s ) 2789s def test_api_custom_dateparsing_error( 2789s conn, request, read_sql, text, mode, error, types_data_frame 2789s ): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2789s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-mysql_pymysql_conn_types] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn_types' 2789s request = > 2789s read_sql = , text = 'SELECT * FROM types' 2789s mode = ('sqlalchemy', 'fallback'), error = 'ignore' 2789s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2789s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2789s 1 first 2000-01-04 00:00:00 ... NaN NaN 2789s 2789s [2 rows x 9 columns] 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2789s @pytest.mark.parametrize( 2789s "read_sql, text, mode", 2789s [ 2789s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2789s (sql.read_sql, "types", ("sqlalchemy")), 2789s ( 2789s sql.read_sql_query, 2789s "SELECT * FROM types", 2789s ("sqlalchemy", "fallback"), 2789s ), 2789s (sql.read_sql_table, "types", ("sqlalchemy")), 2789s ], 2789s ) 2789s def test_api_custom_dateparsing_error( 2789s conn, request, read_sql, text, mode, error, types_data_frame 2789s ): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2789s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-postgresql_psycopg2_engine_types] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_engine_types' 2789s request = > 2789s read_sql = , text = 'SELECT * FROM types' 2789s mode = ('sqlalchemy', 'fallback'), error = 'ignore' 2789s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2789s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2789s 1 first 2000-01-04 00:00:00 ... NaN NaN 2789s 2789s [2 rows x 9 columns] 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2789s @pytest.mark.parametrize( 2789s "read_sql, text, mode", 2789s [ 2789s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2789s (sql.read_sql, "types", ("sqlalchemy")), 2789s ( 2789s sql.read_sql_query, 2789s "SELECT * FROM types", 2789s ("sqlalchemy", "fallback"), 2789s ), 2789s (sql.read_sql_table, "types", ("sqlalchemy")), 2789s ], 2789s ) 2789s def test_api_custom_dateparsing_error( 2789s conn, request, read_sql, text, mode, error, types_data_frame 2789s ): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2789s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-postgresql_psycopg2_conn_types] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn_types' 2789s request = > 2789s read_sql = , text = 'SELECT * FROM types' 2789s mode = ('sqlalchemy', 'fallback'), error = 'ignore' 2789s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2789s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2789s 1 first 2000-01-04 00:00:00 ... NaN NaN 2789s 2789s [2 rows x 9 columns] 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2789s @pytest.mark.parametrize( 2789s "read_sql, text, mode", 2789s [ 2789s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2789s (sql.read_sql, "types", ("sqlalchemy")), 2789s ( 2789s sql.read_sql_query, 2789s "SELECT * FROM types", 2789s ("sqlalchemy", "fallback"), 2789s ), 2789s (sql.read_sql_table, "types", ("sqlalchemy")), 2789s ], 2789s ) 2789s def test_api_custom_dateparsing_error( 2789s conn, request, read_sql, text, mode, error, types_data_frame 2789s ): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2789s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-mysql_pymysql_engine_types] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_engine_types' 2789s request = > 2789s read_sql = , text = 'SELECT * FROM types' 2789s mode = ('sqlalchemy', 'fallback'), error = 'raise' 2789s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2789s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2789s 1 first 2000-01-04 00:00:00 ... NaN NaN 2789s 2789s [2 rows x 9 columns] 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2789s @pytest.mark.parametrize( 2789s "read_sql, text, mode", 2789s [ 2789s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2789s (sql.read_sql, "types", ("sqlalchemy")), 2789s ( 2789s sql.read_sql_query, 2789s "SELECT * FROM types", 2789s ("sqlalchemy", "fallback"), 2789s ), 2789s (sql.read_sql_table, "types", ("sqlalchemy")), 2789s ], 2789s ) 2789s def test_api_custom_dateparsing_error( 2789s conn, request, read_sql, text, mode, error, types_data_frame 2789s ): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2789s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-mysql_pymysql_conn_types] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn_types' 2789s request = > 2789s read_sql = , text = 'SELECT * FROM types' 2789s mode = ('sqlalchemy', 'fallback'), error = 'raise' 2789s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2789s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2789s 1 first 2000-01-04 00:00:00 ... NaN NaN 2789s 2789s [2 rows x 9 columns] 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2789s @pytest.mark.parametrize( 2789s "read_sql, text, mode", 2789s [ 2789s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2789s (sql.read_sql, "types", ("sqlalchemy")), 2789s ( 2789s sql.read_sql_query, 2789s "SELECT * FROM types", 2789s ("sqlalchemy", "fallback"), 2789s ), 2789s (sql.read_sql_table, "types", ("sqlalchemy")), 2789s ], 2789s ) 2789s def test_api_custom_dateparsing_error( 2789s conn, request, read_sql, text, mode, error, types_data_frame 2789s ): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2789s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-postgresql_psycopg2_engine_types] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_engine_types' 2789s request = > 2789s read_sql = , text = 'SELECT * FROM types' 2789s mode = ('sqlalchemy', 'fallback'), error = 'raise' 2789s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2789s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2789s 1 first 2000-01-04 00:00:00 ... NaN NaN 2789s 2789s [2 rows x 9 columns] 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2789s @pytest.mark.parametrize( 2789s "read_sql, text, mode", 2789s [ 2789s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2789s (sql.read_sql, "types", ("sqlalchemy")), 2789s ( 2789s sql.read_sql_query, 2789s "SELECT * FROM types", 2789s ("sqlalchemy", "fallback"), 2789s ), 2789s (sql.read_sql_table, "types", ("sqlalchemy")), 2789s ], 2789s ) 2789s def test_api_custom_dateparsing_error( 2789s conn, request, read_sql, text, mode, error, types_data_frame 2789s ): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2789s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-postgresql_psycopg2_conn_types] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn_types' 2789s request = > 2789s read_sql = , text = 'SELECT * FROM types' 2789s mode = ('sqlalchemy', 'fallback'), error = 'raise' 2789s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2789s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2789s 1 first 2000-01-04 00:00:00 ... NaN NaN 2789s 2789s [2 rows x 9 columns] 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2789s @pytest.mark.parametrize( 2789s "read_sql, text, mode", 2789s [ 2789s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2789s (sql.read_sql, "types", ("sqlalchemy")), 2789s ( 2789s sql.read_sql_query, 2789s "SELECT * FROM types", 2789s ("sqlalchemy", "fallback"), 2789s ), 2789s (sql.read_sql_table, "types", ("sqlalchemy")), 2789s ], 2789s ) 2789s def test_api_custom_dateparsing_error( 2789s conn, request, read_sql, text, mode, error, types_data_frame 2789s ): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2789s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-mysql_pymysql_engine_types] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_engine_types' 2789s request = > 2789s read_sql = , text = 'SELECT * FROM types' 2789s mode = ('sqlalchemy', 'fallback'), error = 'coerce' 2789s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2789s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2789s 1 first 2000-01-04 00:00:00 ... NaN NaN 2789s 2789s [2 rows x 9 columns] 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2789s @pytest.mark.parametrize( 2789s "read_sql, text, mode", 2789s [ 2789s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2789s (sql.read_sql, "types", ("sqlalchemy")), 2789s ( 2789s sql.read_sql_query, 2789s "SELECT * FROM types", 2789s ("sqlalchemy", "fallback"), 2789s ), 2789s (sql.read_sql_table, "types", ("sqlalchemy")), 2789s ], 2789s ) 2789s def test_api_custom_dateparsing_error( 2789s conn, request, read_sql, text, mode, error, types_data_frame 2789s ): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2789s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-mysql_pymysql_conn_types] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn_types' 2789s request = > 2789s read_sql = , text = 'SELECT * FROM types' 2789s mode = ('sqlalchemy', 'fallback'), error = 'coerce' 2789s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2789s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2789s 1 first 2000-01-04 00:00:00 ... NaN NaN 2789s 2789s [2 rows x 9 columns] 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2789s @pytest.mark.parametrize( 2789s "read_sql, text, mode", 2789s [ 2789s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2789s (sql.read_sql, "types", ("sqlalchemy")), 2789s ( 2789s sql.read_sql_query, 2789s "SELECT * FROM types", 2789s ("sqlalchemy", "fallback"), 2789s ), 2789s (sql.read_sql_table, "types", ("sqlalchemy")), 2789s ], 2789s ) 2789s def test_api_custom_dateparsing_error( 2789s conn, request, read_sql, text, mode, error, types_data_frame 2789s ): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2789s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-postgresql_psycopg2_engine_types] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_engine_types' 2789s request = > 2789s read_sql = , text = 'SELECT * FROM types' 2789s mode = ('sqlalchemy', 'fallback'), error = 'coerce' 2789s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2789s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2789s 1 first 2000-01-04 00:00:00 ... NaN NaN 2789s 2789s [2 rows x 9 columns] 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2789s @pytest.mark.parametrize( 2789s "read_sql, text, mode", 2789s [ 2789s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2789s (sql.read_sql, "types", ("sqlalchemy")), 2789s ( 2789s sql.read_sql_query, 2789s "SELECT * FROM types", 2789s ("sqlalchemy", "fallback"), 2789s ), 2789s (sql.read_sql_table, "types", ("sqlalchemy")), 2789s ], 2789s ) 2789s def test_api_custom_dateparsing_error( 2789s conn, request, read_sql, text, mode, error, types_data_frame 2789s ): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2789s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-postgresql_psycopg2_conn_types] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn_types' 2789s request = > 2789s read_sql = , text = 'SELECT * FROM types' 2789s mode = ('sqlalchemy', 'fallback'), error = 'coerce' 2789s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2789s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2789s 1 first 2000-01-04 00:00:00 ... NaN NaN 2789s 2789s [2 rows x 9 columns] 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2789s @pytest.mark.parametrize( 2789s "read_sql, text, mode", 2789s [ 2789s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2789s (sql.read_sql, "types", ("sqlalchemy")), 2789s ( 2789s sql.read_sql_query, 2789s "SELECT * FROM types", 2789s ("sqlalchemy", "fallback"), 2789s ), 2789s (sql.read_sql_table, "types", ("sqlalchemy")), 2789s ], 2789s ) 2789s def test_api_custom_dateparsing_error( 2789s conn, request, read_sql, text, mode, error, types_data_frame 2789s ): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2789s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-mysql_pymysql_engine_types] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_engine_types' 2789s request = > 2789s read_sql = , text = 'types' 2789s mode = 'sqlalchemy', error = 'ignore' 2789s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2789s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2789s 1 first 2000-01-04 00:00:00 ... NaN NaN 2789s 2789s [2 rows x 9 columns] 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2789s @pytest.mark.parametrize( 2789s "read_sql, text, mode", 2789s [ 2789s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2789s (sql.read_sql, "types", ("sqlalchemy")), 2789s ( 2789s sql.read_sql_query, 2789s "SELECT * FROM types", 2789s ("sqlalchemy", "fallback"), 2789s ), 2789s (sql.read_sql_table, "types", ("sqlalchemy")), 2789s ], 2789s ) 2789s def test_api_custom_dateparsing_error( 2789s conn, request, read_sql, text, mode, error, types_data_frame 2789s ): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2789s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-mysql_pymysql_conn_types] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn_types' 2789s request = > 2789s read_sql = , text = 'types' 2789s mode = 'sqlalchemy', error = 'ignore' 2789s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2789s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2789s 1 first 2000-01-04 00:00:00 ... NaN NaN 2789s 2789s [2 rows x 9 columns] 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2789s @pytest.mark.parametrize( 2789s "read_sql, text, mode", 2789s [ 2789s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2789s (sql.read_sql, "types", ("sqlalchemy")), 2789s ( 2789s sql.read_sql_query, 2789s "SELECT * FROM types", 2789s ("sqlalchemy", "fallback"), 2789s ), 2789s (sql.read_sql_table, "types", ("sqlalchemy")), 2789s ], 2789s ) 2789s def test_api_custom_dateparsing_error( 2789s conn, request, read_sql, text, mode, error, types_data_frame 2789s ): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2789s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-postgresql_psycopg2_engine_types] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_engine_types' 2789s request = > 2789s read_sql = , text = 'types' 2789s mode = 'sqlalchemy', error = 'ignore' 2789s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2789s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2789s 1 first 2000-01-04 00:00:00 ... NaN NaN 2789s 2789s [2 rows x 9 columns] 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2789s @pytest.mark.parametrize( 2789s "read_sql, text, mode", 2789s [ 2789s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2789s (sql.read_sql, "types", ("sqlalchemy")), 2789s ( 2789s sql.read_sql_query, 2789s "SELECT * FROM types", 2789s ("sqlalchemy", "fallback"), 2789s ), 2789s (sql.read_sql_table, "types", ("sqlalchemy")), 2789s ], 2789s ) 2789s def test_api_custom_dateparsing_error( 2789s conn, request, read_sql, text, mode, error, types_data_frame 2789s ): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2789s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-postgresql_psycopg2_conn_types] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn_types' 2789s request = > 2789s read_sql = , text = 'types' 2789s mode = 'sqlalchemy', error = 'ignore' 2789s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2789s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2789s 1 first 2000-01-04 00:00:00 ... NaN NaN 2789s 2789s [2 rows x 9 columns] 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2789s @pytest.mark.parametrize( 2789s "read_sql, text, mode", 2789s [ 2789s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2789s (sql.read_sql, "types", ("sqlalchemy")), 2789s ( 2789s sql.read_sql_query, 2789s "SELECT * FROM types", 2789s ("sqlalchemy", "fallback"), 2789s ), 2789s (sql.read_sql_table, "types", ("sqlalchemy")), 2789s ], 2789s ) 2789s def test_api_custom_dateparsing_error( 2789s conn, request, read_sql, text, mode, error, types_data_frame 2789s ): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2789s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-mysql_pymysql_engine_types] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_engine_types' 2789s request = > 2789s read_sql = , text = 'types' 2789s mode = 'sqlalchemy', error = 'raise' 2789s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2789s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2789s 1 first 2000-01-04 00:00:00 ... NaN NaN 2789s 2789s [2 rows x 9 columns] 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2789s @pytest.mark.parametrize( 2789s "read_sql, text, mode", 2789s [ 2789s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2789s (sql.read_sql, "types", ("sqlalchemy")), 2789s ( 2789s sql.read_sql_query, 2789s "SELECT * FROM types", 2789s ("sqlalchemy", "fallback"), 2789s ), 2789s (sql.read_sql_table, "types", ("sqlalchemy")), 2789s ], 2789s ) 2789s def test_api_custom_dateparsing_error( 2789s conn, request, read_sql, text, mode, error, types_data_frame 2789s ): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2789s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-mysql_pymysql_conn_types] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn_types' 2789s request = > 2789s read_sql = , text = 'types' 2789s mode = 'sqlalchemy', error = 'raise' 2789s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2789s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2789s 1 first 2000-01-04 00:00:00 ... NaN NaN 2789s 2789s [2 rows x 9 columns] 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2789s @pytest.mark.parametrize( 2789s "read_sql, text, mode", 2789s [ 2789s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2789s (sql.read_sql, "types", ("sqlalchemy")), 2789s ( 2789s sql.read_sql_query, 2789s "SELECT * FROM types", 2789s ("sqlalchemy", "fallback"), 2789s ), 2789s (sql.read_sql_table, "types", ("sqlalchemy")), 2789s ], 2789s ) 2789s def test_api_custom_dateparsing_error( 2789s conn, request, read_sql, text, mode, error, types_data_frame 2789s ): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2789s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-postgresql_psycopg2_engine_types] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_engine_types' 2789s request = > 2789s read_sql = , text = 'types' 2789s mode = 'sqlalchemy', error = 'raise' 2789s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2789s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2789s 1 first 2000-01-04 00:00:00 ... NaN NaN 2789s 2789s [2 rows x 9 columns] 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2789s @pytest.mark.parametrize( 2789s "read_sql, text, mode", 2789s [ 2789s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2789s (sql.read_sql, "types", ("sqlalchemy")), 2789s ( 2789s sql.read_sql_query, 2789s "SELECT * FROM types", 2789s ("sqlalchemy", "fallback"), 2789s ), 2789s (sql.read_sql_table, "types", ("sqlalchemy")), 2789s ], 2789s ) 2789s def test_api_custom_dateparsing_error( 2789s conn, request, read_sql, text, mode, error, types_data_frame 2789s ): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2789s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-postgresql_psycopg2_conn_types] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn_types' 2789s request = > 2789s read_sql = , text = 'types' 2789s mode = 'sqlalchemy', error = 'raise' 2789s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2789s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2789s 1 first 2000-01-04 00:00:00 ... NaN NaN 2789s 2789s [2 rows x 9 columns] 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2789s @pytest.mark.parametrize( 2789s "read_sql, text, mode", 2789s [ 2789s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2789s (sql.read_sql, "types", ("sqlalchemy")), 2789s ( 2789s sql.read_sql_query, 2789s "SELECT * FROM types", 2789s ("sqlalchemy", "fallback"), 2789s ), 2789s (sql.read_sql_table, "types", ("sqlalchemy")), 2789s ], 2789s ) 2789s def test_api_custom_dateparsing_error( 2789s conn, request, read_sql, text, mode, error, types_data_frame 2789s ): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2789s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-mysql_pymysql_engine_types] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_engine_types' 2789s request = > 2789s read_sql = , text = 'types' 2789s mode = 'sqlalchemy', error = 'coerce' 2789s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2789s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2789s 1 first 2000-01-04 00:00:00 ... NaN NaN 2789s 2789s [2 rows x 9 columns] 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2789s @pytest.mark.parametrize( 2789s "read_sql, text, mode", 2789s [ 2789s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2789s (sql.read_sql, "types", ("sqlalchemy")), 2789s ( 2789s sql.read_sql_query, 2789s "SELECT * FROM types", 2789s ("sqlalchemy", "fallback"), 2789s ), 2789s (sql.read_sql_table, "types", ("sqlalchemy")), 2789s ], 2789s ) 2789s def test_api_custom_dateparsing_error( 2789s conn, request, read_sql, text, mode, error, types_data_frame 2789s ): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2789s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-mysql_pymysql_conn_types] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn_types' 2789s request = > 2789s read_sql = , text = 'types' 2789s mode = 'sqlalchemy', error = 'coerce' 2789s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2789s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2789s 1 first 2000-01-04 00:00:00 ... NaN NaN 2789s 2789s [2 rows x 9 columns] 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2789s @pytest.mark.parametrize( 2789s "read_sql, text, mode", 2789s [ 2789s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2789s (sql.read_sql, "types", ("sqlalchemy")), 2789s ( 2789s sql.read_sql_query, 2789s "SELECT * FROM types", 2789s ("sqlalchemy", "fallback"), 2789s ), 2789s (sql.read_sql_table, "types", ("sqlalchemy")), 2789s ], 2789s ) 2789s def test_api_custom_dateparsing_error( 2789s conn, request, read_sql, text, mode, error, types_data_frame 2789s ): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2789s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-postgresql_psycopg2_engine_types] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_engine_types' 2789s request = > 2789s read_sql = , text = 'types' 2789s mode = 'sqlalchemy', error = 'coerce' 2789s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2789s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2789s 1 first 2000-01-04 00:00:00 ... NaN NaN 2789s 2789s [2 rows x 9 columns] 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2789s @pytest.mark.parametrize( 2789s "read_sql, text, mode", 2789s [ 2789s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2789s (sql.read_sql, "types", ("sqlalchemy")), 2789s ( 2789s sql.read_sql_query, 2789s "SELECT * FROM types", 2789s ("sqlalchemy", "fallback"), 2789s ), 2789s (sql.read_sql_table, "types", ("sqlalchemy")), 2789s ], 2789s ) 2789s def test_api_custom_dateparsing_error( 2789s conn, request, read_sql, text, mode, error, types_data_frame 2789s ): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2789s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-postgresql_psycopg2_conn_types] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn_types' 2789s request = > 2789s read_sql = , text = 'types' 2789s mode = 'sqlalchemy', error = 'coerce' 2789s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2789s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2789s 1 first 2000-01-04 00:00:00 ... NaN NaN 2789s 2789s [2 rows x 9 columns] 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2789s @pytest.mark.parametrize( 2789s "read_sql, text, mode", 2789s [ 2789s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2789s (sql.read_sql, "types", ("sqlalchemy")), 2789s ( 2789s sql.read_sql_query, 2789s "SELECT * FROM types", 2789s ("sqlalchemy", "fallback"), 2789s ), 2789s (sql.read_sql_table, "types", ("sqlalchemy")), 2789s ], 2789s ) 2789s def test_api_custom_dateparsing_error( 2789s conn, request, read_sql, text, mode, error, types_data_frame 2789s ): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2789s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-mysql_pymysql_engine_types] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_engine_types' 2789s request = > 2789s read_sql = , text = 'SELECT * FROM types' 2789s mode = ('sqlalchemy', 'fallback'), error = 'ignore' 2789s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2789s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2789s 1 first 2000-01-04 00:00:00 ... NaN NaN 2789s 2789s [2 rows x 9 columns] 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2789s @pytest.mark.parametrize( 2789s "read_sql, text, mode", 2789s [ 2789s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2789s (sql.read_sql, "types", ("sqlalchemy")), 2789s ( 2789s sql.read_sql_query, 2789s "SELECT * FROM types", 2789s ("sqlalchemy", "fallback"), 2789s ), 2789s (sql.read_sql_table, "types", ("sqlalchemy")), 2789s ], 2789s ) 2789s def test_api_custom_dateparsing_error( 2789s conn, request, read_sql, text, mode, error, types_data_frame 2789s ): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2789s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-mysql_pymysql_conn_types] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn_types' 2789s request = > 2789s read_sql = , text = 'SELECT * FROM types' 2789s mode = ('sqlalchemy', 'fallback'), error = 'ignore' 2789s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2789s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2789s 1 first 2000-01-04 00:00:00 ... NaN NaN 2789s 2789s [2 rows x 9 columns] 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2789s @pytest.mark.parametrize( 2789s "read_sql, text, mode", 2789s [ 2789s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2789s (sql.read_sql, "types", ("sqlalchemy")), 2789s ( 2789s sql.read_sql_query, 2789s "SELECT * FROM types", 2789s ("sqlalchemy", "fallback"), 2789s ), 2789s (sql.read_sql_table, "types", ("sqlalchemy")), 2789s ], 2789s ) 2789s def test_api_custom_dateparsing_error( 2789s conn, request, read_sql, text, mode, error, types_data_frame 2789s ): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2789s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-postgresql_psycopg2_engine_types] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_engine_types' 2789s request = > 2789s read_sql = , text = 'SELECT * FROM types' 2789s mode = ('sqlalchemy', 'fallback'), error = 'ignore' 2789s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2789s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2789s 1 first 2000-01-04 00:00:00 ... NaN NaN 2789s 2789s [2 rows x 9 columns] 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2789s @pytest.mark.parametrize( 2789s "read_sql, text, mode", 2789s [ 2789s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2789s (sql.read_sql, "types", ("sqlalchemy")), 2789s ( 2789s sql.read_sql_query, 2789s "SELECT * FROM types", 2789s ("sqlalchemy", "fallback"), 2789s ), 2789s (sql.read_sql_table, "types", ("sqlalchemy")), 2789s ], 2789s ) 2789s def test_api_custom_dateparsing_error( 2789s conn, request, read_sql, text, mode, error, types_data_frame 2789s ): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2789s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-postgresql_psycopg2_conn_types] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn_types' 2789s request = > 2789s read_sql = , text = 'SELECT * FROM types' 2789s mode = ('sqlalchemy', 'fallback'), error = 'ignore' 2789s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2789s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2789s 1 first 2000-01-04 00:00:00 ... NaN NaN 2789s 2789s [2 rows x 9 columns] 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2789s @pytest.mark.parametrize( 2789s "read_sql, text, mode", 2789s [ 2789s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2789s (sql.read_sql, "types", ("sqlalchemy")), 2789s ( 2789s sql.read_sql_query, 2789s "SELECT * FROM types", 2789s ("sqlalchemy", "fallback"), 2789s ), 2789s (sql.read_sql_table, "types", ("sqlalchemy")), 2789s ], 2789s ) 2789s def test_api_custom_dateparsing_error( 2789s conn, request, read_sql, text, mode, error, types_data_frame 2789s ): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2789s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-mysql_pymysql_engine_types] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_engine_types' 2789s request = > 2789s read_sql = , text = 'SELECT * FROM types' 2789s mode = ('sqlalchemy', 'fallback'), error = 'raise' 2789s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2789s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2789s 1 first 2000-01-04 00:00:00 ... NaN NaN 2789s 2789s [2 rows x 9 columns] 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2789s @pytest.mark.parametrize( 2789s "read_sql, text, mode", 2789s [ 2789s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2789s (sql.read_sql, "types", ("sqlalchemy")), 2789s ( 2789s sql.read_sql_query, 2789s "SELECT * FROM types", 2789s ("sqlalchemy", "fallback"), 2789s ), 2789s (sql.read_sql_table, "types", ("sqlalchemy")), 2789s ], 2789s ) 2789s def test_api_custom_dateparsing_error( 2789s conn, request, read_sql, text, mode, error, types_data_frame 2789s ): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2789s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-mysql_pymysql_conn_types] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn_types' 2789s request = > 2789s read_sql = , text = 'SELECT * FROM types' 2789s mode = ('sqlalchemy', 'fallback'), error = 'raise' 2789s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2789s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2789s 1 first 2000-01-04 00:00:00 ... NaN NaN 2789s 2789s [2 rows x 9 columns] 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2789s @pytest.mark.parametrize( 2789s "read_sql, text, mode", 2789s [ 2789s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2789s (sql.read_sql, "types", ("sqlalchemy")), 2789s ( 2789s sql.read_sql_query, 2789s "SELECT * FROM types", 2789s ("sqlalchemy", "fallback"), 2789s ), 2789s (sql.read_sql_table, "types", ("sqlalchemy")), 2789s ], 2789s ) 2789s def test_api_custom_dateparsing_error( 2789s conn, request, read_sql, text, mode, error, types_data_frame 2789s ): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2789s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-postgresql_psycopg2_engine_types] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_engine_types' 2789s request = > 2789s read_sql = , text = 'SELECT * FROM types' 2789s mode = ('sqlalchemy', 'fallback'), error = 'raise' 2789s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2789s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2789s 1 first 2000-01-04 00:00:00 ... NaN NaN 2789s 2789s [2 rows x 9 columns] 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2789s @pytest.mark.parametrize( 2789s "read_sql, text, mode", 2789s [ 2789s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2789s (sql.read_sql, "types", ("sqlalchemy")), 2789s ( 2789s sql.read_sql_query, 2789s "SELECT * FROM types", 2789s ("sqlalchemy", "fallback"), 2789s ), 2789s (sql.read_sql_table, "types", ("sqlalchemy")), 2789s ], 2789s ) 2789s def test_api_custom_dateparsing_error( 2789s conn, request, read_sql, text, mode, error, types_data_frame 2789s ): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2789s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-postgresql_psycopg2_conn_types] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn_types' 2789s request = > 2789s read_sql = , text = 'SELECT * FROM types' 2789s mode = ('sqlalchemy', 'fallback'), error = 'raise' 2789s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2789s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2789s 1 first 2000-01-04 00:00:00 ... NaN NaN 2789s 2789s [2 rows x 9 columns] 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2789s @pytest.mark.parametrize( 2789s "read_sql, text, mode", 2789s [ 2789s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2789s (sql.read_sql, "types", ("sqlalchemy")), 2789s ( 2789s sql.read_sql_query, 2789s "SELECT * FROM types", 2789s ("sqlalchemy", "fallback"), 2789s ), 2789s (sql.read_sql_table, "types", ("sqlalchemy")), 2789s ], 2789s ) 2789s def test_api_custom_dateparsing_error( 2789s conn, request, read_sql, text, mode, error, types_data_frame 2789s ): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2789s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-mysql_pymysql_engine_types] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_engine_types' 2789s request = > 2789s read_sql = , text = 'SELECT * FROM types' 2789s mode = ('sqlalchemy', 'fallback'), error = 'coerce' 2789s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2789s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2789s 1 first 2000-01-04 00:00:00 ... NaN NaN 2789s 2789s [2 rows x 9 columns] 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2789s @pytest.mark.parametrize( 2789s "read_sql, text, mode", 2789s [ 2789s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2789s (sql.read_sql, "types", ("sqlalchemy")), 2789s ( 2789s sql.read_sql_query, 2789s "SELECT * FROM types", 2789s ("sqlalchemy", "fallback"), 2789s ), 2789s (sql.read_sql_table, "types", ("sqlalchemy")), 2789s ], 2789s ) 2789s def test_api_custom_dateparsing_error( 2789s conn, request, read_sql, text, mode, error, types_data_frame 2789s ): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2789s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-mysql_pymysql_conn_types] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn_types' 2789s request = > 2789s read_sql = , text = 'SELECT * FROM types' 2789s mode = ('sqlalchemy', 'fallback'), error = 'coerce' 2789s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2789s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2789s 1 first 2000-01-04 00:00:00 ... NaN NaN 2789s 2789s [2 rows x 9 columns] 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2789s @pytest.mark.parametrize( 2789s "read_sql, text, mode", 2789s [ 2789s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2789s (sql.read_sql, "types", ("sqlalchemy")), 2789s ( 2789s sql.read_sql_query, 2789s "SELECT * FROM types", 2789s ("sqlalchemy", "fallback"), 2789s ), 2789s (sql.read_sql_table, "types", ("sqlalchemy")), 2789s ], 2789s ) 2789s def test_api_custom_dateparsing_error( 2789s conn, request, read_sql, text, mode, error, types_data_frame 2789s ): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2789s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-postgresql_psycopg2_engine_types] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_engine_types' 2789s request = > 2789s read_sql = , text = 'SELECT * FROM types' 2789s mode = ('sqlalchemy', 'fallback'), error = 'coerce' 2789s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2789s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2789s 1 first 2000-01-04 00:00:00 ... NaN NaN 2789s 2789s [2 rows x 9 columns] 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2789s @pytest.mark.parametrize( 2789s "read_sql, text, mode", 2789s [ 2789s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2789s (sql.read_sql, "types", ("sqlalchemy")), 2789s ( 2789s sql.read_sql_query, 2789s "SELECT * FROM types", 2789s ("sqlalchemy", "fallback"), 2789s ), 2789s (sql.read_sql_table, "types", ("sqlalchemy")), 2789s ], 2789s ) 2789s def test_api_custom_dateparsing_error( 2789s conn, request, read_sql, text, mode, error, types_data_frame 2789s ): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2789s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-postgresql_psycopg2_conn_types] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn_types' 2789s request = > 2789s read_sql = , text = 'SELECT * FROM types' 2789s mode = ('sqlalchemy', 'fallback'), error = 'coerce' 2789s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2789s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2789s 1 first 2000-01-04 00:00:00 ... NaN NaN 2789s 2789s [2 rows x 9 columns] 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2789s @pytest.mark.parametrize( 2789s "read_sql, text, mode", 2789s [ 2789s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2789s (sql.read_sql, "types", ("sqlalchemy")), 2789s ( 2789s sql.read_sql_query, 2789s "SELECT * FROM types", 2789s ("sqlalchemy", "fallback"), 2789s ), 2789s (sql.read_sql_table, "types", ("sqlalchemy")), 2789s ], 2789s ) 2789s def test_api_custom_dateparsing_error( 2789s conn, request, read_sql, text, mode, error, types_data_frame 2789s ): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2789s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-mysql_pymysql_engine_types] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_engine_types' 2789s request = > 2789s read_sql = , text = 'types' 2789s mode = 'sqlalchemy', error = 'ignore' 2789s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2789s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2789s 1 first 2000-01-04 00:00:00 ... NaN NaN 2789s 2789s [2 rows x 9 columns] 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2789s @pytest.mark.parametrize( 2789s "read_sql, text, mode", 2789s [ 2789s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2789s (sql.read_sql, "types", ("sqlalchemy")), 2789s ( 2789s sql.read_sql_query, 2789s "SELECT * FROM types", 2789s ("sqlalchemy", "fallback"), 2789s ), 2789s (sql.read_sql_table, "types", ("sqlalchemy")), 2789s ], 2789s ) 2789s def test_api_custom_dateparsing_error( 2789s conn, request, read_sql, text, mode, error, types_data_frame 2789s ): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2789s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-mysql_pymysql_conn_types] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn_types' 2789s request = > 2789s read_sql = , text = 'types' 2789s mode = 'sqlalchemy', error = 'ignore' 2789s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2789s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2789s 1 first 2000-01-04 00:00:00 ... NaN NaN 2789s 2789s [2 rows x 9 columns] 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2789s @pytest.mark.parametrize( 2789s "read_sql, text, mode", 2789s [ 2789s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2789s (sql.read_sql, "types", ("sqlalchemy")), 2789s ( 2789s sql.read_sql_query, 2789s "SELECT * FROM types", 2789s ("sqlalchemy", "fallback"), 2789s ), 2789s (sql.read_sql_table, "types", ("sqlalchemy")), 2789s ], 2789s ) 2789s def test_api_custom_dateparsing_error( 2789s conn, request, read_sql, text, mode, error, types_data_frame 2789s ): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2789s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-postgresql_psycopg2_engine_types] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_engine_types' 2789s request = > 2789s read_sql = , text = 'types' 2789s mode = 'sqlalchemy', error = 'ignore' 2789s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2789s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2789s 1 first 2000-01-04 00:00:00 ... NaN NaN 2789s 2789s [2 rows x 9 columns] 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2789s @pytest.mark.parametrize( 2789s "read_sql, text, mode", 2789s [ 2789s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2789s (sql.read_sql, "types", ("sqlalchemy")), 2789s ( 2789s sql.read_sql_query, 2789s "SELECT * FROM types", 2789s ("sqlalchemy", "fallback"), 2789s ), 2789s (sql.read_sql_table, "types", ("sqlalchemy")), 2789s ], 2789s ) 2789s def test_api_custom_dateparsing_error( 2789s conn, request, read_sql, text, mode, error, types_data_frame 2789s ): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2789s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-postgresql_psycopg2_conn_types] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn_types' 2789s request = > 2789s read_sql = , text = 'types' 2789s mode = 'sqlalchemy', error = 'ignore' 2789s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2789s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2789s 1 first 2000-01-04 00:00:00 ... NaN NaN 2789s 2789s [2 rows x 9 columns] 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2789s @pytest.mark.parametrize( 2789s "read_sql, text, mode", 2789s [ 2789s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2789s (sql.read_sql, "types", ("sqlalchemy")), 2789s ( 2789s sql.read_sql_query, 2789s "SELECT * FROM types", 2789s ("sqlalchemy", "fallback"), 2789s ), 2789s (sql.read_sql_table, "types", ("sqlalchemy")), 2789s ], 2789s ) 2789s def test_api_custom_dateparsing_error( 2789s conn, request, read_sql, text, mode, error, types_data_frame 2789s ): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2789s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-mysql_pymysql_engine_types] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_engine_types' 2789s request = > 2789s read_sql = , text = 'types' 2789s mode = 'sqlalchemy', error = 'raise' 2789s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2789s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2789s 1 first 2000-01-04 00:00:00 ... NaN NaN 2789s 2789s [2 rows x 9 columns] 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2789s @pytest.mark.parametrize( 2789s "read_sql, text, mode", 2789s [ 2789s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2789s (sql.read_sql, "types", ("sqlalchemy")), 2789s ( 2789s sql.read_sql_query, 2789s "SELECT * FROM types", 2789s ("sqlalchemy", "fallback"), 2789s ), 2789s (sql.read_sql_table, "types", ("sqlalchemy")), 2789s ], 2789s ) 2789s def test_api_custom_dateparsing_error( 2789s conn, request, read_sql, text, mode, error, types_data_frame 2789s ): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2789s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-mysql_pymysql_conn_types] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn_types' 2789s request = > 2789s read_sql = , text = 'types' 2789s mode = 'sqlalchemy', error = 'raise' 2789s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2789s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2789s 1 first 2000-01-04 00:00:00 ... NaN NaN 2789s 2789s [2 rows x 9 columns] 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2789s @pytest.mark.parametrize( 2789s "read_sql, text, mode", 2789s [ 2789s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2789s (sql.read_sql, "types", ("sqlalchemy")), 2789s ( 2789s sql.read_sql_query, 2789s "SELECT * FROM types", 2789s ("sqlalchemy", "fallback"), 2789s ), 2789s (sql.read_sql_table, "types", ("sqlalchemy")), 2789s ], 2789s ) 2789s def test_api_custom_dateparsing_error( 2789s conn, request, read_sql, text, mode, error, types_data_frame 2789s ): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2789s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-postgresql_psycopg2_engine_types] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_engine_types' 2789s request = > 2789s read_sql = , text = 'types' 2789s mode = 'sqlalchemy', error = 'raise' 2789s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2789s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2789s 1 first 2000-01-04 00:00:00 ... NaN NaN 2789s 2789s [2 rows x 9 columns] 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2789s @pytest.mark.parametrize( 2789s "read_sql, text, mode", 2789s [ 2789s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2789s (sql.read_sql, "types", ("sqlalchemy")), 2789s ( 2789s sql.read_sql_query, 2789s "SELECT * FROM types", 2789s ("sqlalchemy", "fallback"), 2789s ), 2789s (sql.read_sql_table, "types", ("sqlalchemy")), 2789s ], 2789s ) 2789s def test_api_custom_dateparsing_error( 2789s conn, request, read_sql, text, mode, error, types_data_frame 2789s ): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2789s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-postgresql_psycopg2_conn_types] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn_types' 2789s request = > 2789s read_sql = , text = 'types' 2789s mode = 'sqlalchemy', error = 'raise' 2789s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2789s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2789s 1 first 2000-01-04 00:00:00 ... NaN NaN 2789s 2789s [2 rows x 9 columns] 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2789s @pytest.mark.parametrize( 2789s "read_sql, text, mode", 2789s [ 2789s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2789s (sql.read_sql, "types", ("sqlalchemy")), 2789s ( 2789s sql.read_sql_query, 2789s "SELECT * FROM types", 2789s ("sqlalchemy", "fallback"), 2789s ), 2789s (sql.read_sql_table, "types", ("sqlalchemy")), 2789s ], 2789s ) 2789s def test_api_custom_dateparsing_error( 2789s conn, request, read_sql, text, mode, error, types_data_frame 2789s ): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2789s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-mysql_pymysql_engine_types] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_engine_types' 2789s request = > 2789s read_sql = , text = 'types' 2789s mode = 'sqlalchemy', error = 'coerce' 2789s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2789s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2789s 1 first 2000-01-04 00:00:00 ... NaN NaN 2789s 2789s [2 rows x 9 columns] 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2789s @pytest.mark.parametrize( 2789s "read_sql, text, mode", 2789s [ 2789s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2789s (sql.read_sql, "types", ("sqlalchemy")), 2789s ( 2789s sql.read_sql_query, 2789s "SELECT * FROM types", 2789s ("sqlalchemy", "fallback"), 2789s ), 2789s (sql.read_sql_table, "types", ("sqlalchemy")), 2789s ], 2789s ) 2789s def test_api_custom_dateparsing_error( 2789s conn, request, read_sql, text, mode, error, types_data_frame 2789s ): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2789s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-mysql_pymysql_conn_types] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn_types' 2789s request = > 2789s read_sql = , text = 'types' 2789s mode = 'sqlalchemy', error = 'coerce' 2789s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2789s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2789s 1 first 2000-01-04 00:00:00 ... NaN NaN 2789s 2789s [2 rows x 9 columns] 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2789s @pytest.mark.parametrize( 2789s "read_sql, text, mode", 2789s [ 2789s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2789s (sql.read_sql, "types", ("sqlalchemy")), 2789s ( 2789s sql.read_sql_query, 2789s "SELECT * FROM types", 2789s ("sqlalchemy", "fallback"), 2789s ), 2789s (sql.read_sql_table, "types", ("sqlalchemy")), 2789s ], 2789s ) 2789s def test_api_custom_dateparsing_error( 2789s conn, request, read_sql, text, mode, error, types_data_frame 2789s ): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2789s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-postgresql_psycopg2_engine_types] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_engine_types' 2789s request = > 2789s read_sql = , text = 'types' 2789s mode = 'sqlalchemy', error = 'coerce' 2789s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2789s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2789s 1 first 2000-01-04 00:00:00 ... NaN NaN 2789s 2789s [2 rows x 9 columns] 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2789s @pytest.mark.parametrize( 2789s "read_sql, text, mode", 2789s [ 2789s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2789s (sql.read_sql, "types", ("sqlalchemy")), 2789s ( 2789s sql.read_sql_query, 2789s "SELECT * FROM types", 2789s ("sqlalchemy", "fallback"), 2789s ), 2789s (sql.read_sql_table, "types", ("sqlalchemy")), 2789s ], 2789s ) 2789s def test_api_custom_dateparsing_error( 2789s conn, request, read_sql, text, mode, error, types_data_frame 2789s ): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2789s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-postgresql_psycopg2_conn_types] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn_types' 2789s request = > 2789s read_sql = , text = 'types' 2789s mode = 'sqlalchemy', error = 'coerce' 2789s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2789s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2789s 1 first 2000-01-04 00:00:00 ... NaN NaN 2789s 2789s [2 rows x 9 columns] 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2789s @pytest.mark.parametrize( 2789s "read_sql, text, mode", 2789s [ 2789s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2789s (sql.read_sql, "types", ("sqlalchemy")), 2789s ( 2789s sql.read_sql_query, 2789s "SELECT * FROM types", 2789s ("sqlalchemy", "fallback"), 2789s ), 2789s (sql.read_sql_table, "types", ("sqlalchemy")), 2789s ], 2789s ) 2789s def test_api_custom_dateparsing_error( 2789s conn, request, read_sql, text, mode, error, types_data_frame 2789s ): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2789s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _____________ test_api_date_and_index[mysql_pymysql_engine_types] ______________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_engine_types' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s def test_api_date_and_index(conn, request): 2789s # Test case where same column appears in parse_date and index_col 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1880: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2789s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ______________ test_api_date_and_index[mysql_pymysql_conn_types] _______________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn_types' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s def test_api_date_and_index(conn, request): 2789s # Test case where same column appears in parse_date and index_col 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1880: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2789s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s __________ test_api_date_and_index[postgresql_psycopg2_engine_types] ___________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_engine_types' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s def test_api_date_and_index(conn, request): 2789s # Test case where same column appears in parse_date and index_col 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1880: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2789s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ___________ test_api_date_and_index[postgresql_psycopg2_conn_types] ____________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn_types' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_types) 2789s def test_api_date_and_index(conn, request): 2789s # Test case where same column appears in parse_date and index_col 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1880: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2789s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2789s with conn.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ___________________ test_api_timedelta[mysql_pymysql_engine] ___________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_timedelta(conn, request): 2789s # see #6921 2789s conn_name = conn 2789s conn = request.getfixturevalue(conn) 2789s > if sql.has_table("test_timedelta", conn): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1897: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2789s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ____________________ test_api_timedelta[mysql_pymysql_conn] ____________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_timedelta(conn, request): 2789s # see #6921 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1896: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ________________ test_api_timedelta[postgresql_psycopg2_engine] ________________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_timedelta(conn, request): 2789s # see #6921 2789s conn_name = conn 2789s conn = request.getfixturevalue(conn) 2789s > if sql.has_table("test_timedelta", conn): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1897: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2789s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _________________ test_api_timedelta[postgresql_psycopg2_conn] _________________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_timedelta(conn, request): 2789s # see #6921 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1896: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ________________ test_api_complex_raises[mysql_pymysql_engine] _________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_complex_raises(conn, request): 2789s conn_name = conn 2789s conn = request.getfixturevalue(conn) 2789s df = DataFrame({"a": [1 + 1j, 2j]}) 2789s 2789s if "adbc" in conn_name: 2789s msg = "datatypes not supported" 2789s else: 2789s msg = "Complex datatypes not supported" 2789s with pytest.raises(ValueError, match=msg): 2789s > assert df.to_sql("test_complex", con=conn) is None 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1950: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2789s return func(*args, **kwargs) 2789s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2789s return sql.to_sql( 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2789s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _________________ test_api_complex_raises[mysql_pymysql_conn] __________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_complex_raises(conn, request): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1942: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _____________ test_api_complex_raises[postgresql_psycopg2_engine] ______________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_complex_raises(conn, request): 2789s conn_name = conn 2789s conn = request.getfixturevalue(conn) 2789s df = DataFrame({"a": [1 + 1j, 2j]}) 2789s 2789s if "adbc" in conn_name: 2789s msg = "datatypes not supported" 2789s else: 2789s msg = "Complex datatypes not supported" 2789s with pytest.raises(ValueError, match=msg): 2789s > assert df.to_sql("test_complex", con=conn) is None 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1950: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2789s return func(*args, **kwargs) 2789s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2789s return sql.to_sql( 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2789s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ______________ test_api_complex_raises[postgresql_psycopg2_conn] _______________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_complex_raises(conn, request): 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1942: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ______ test_api_to_sql_index_label[None-None-index-mysql_pymysql_engine] _______ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2789s request = > 2789s index_name = None, index_label = None, expected = 'index' 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize( 2789s "index_name,index_label,expected", 2789s [ 2789s # no index name, defaults to 'index' 2789s (None, None, "index"), 2789s # specifying index_label 2789s (None, "other_label", "other_label"), 2789s # using the index name 2789s ("index_name", None, "index_name"), 2789s # has index name, but specifying index_label 2789s ("index_name", "other_label", "other_label"), 2789s # index name is integer 2789s (0, None, "0"), 2789s # index name is None but index label is integer 2789s (None, 0, "0"), 2789s ], 2789s ) 2789s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2789s ) 2789s conn = request.getfixturevalue(conn) 2789s > if sql.has_table("test_index_label", conn): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2789s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _______ test_api_to_sql_index_label[None-None-index-mysql_pymysql_conn] ________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn' 2789s request = > 2789s index_name = None, index_label = None, expected = 'index' 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize( 2789s "index_name,index_label,expected", 2789s [ 2789s # no index name, defaults to 'index' 2789s (None, None, "index"), 2789s # specifying index_label 2789s (None, "other_label", "other_label"), 2789s # using the index name 2789s ("index_name", None, "index_name"), 2789s # has index name, but specifying index_label 2789s ("index_name", "other_label", "other_label"), 2789s # index name is integer 2789s (0, None, "0"), 2789s # index name is None but index label is integer 2789s (None, 0, "0"), 2789s ], 2789s ) 2789s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2789s ) 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ___ test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_engine] ____ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s request = > 2789s index_name = None, index_label = None, expected = 'index' 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize( 2789s "index_name,index_label,expected", 2789s [ 2789s # no index name, defaults to 'index' 2789s (None, None, "index"), 2789s # specifying index_label 2789s (None, "other_label", "other_label"), 2789s # using the index name 2789s ("index_name", None, "index_name"), 2789s # has index name, but specifying index_label 2789s ("index_name", "other_label", "other_label"), 2789s # index name is integer 2789s (0, None, "0"), 2789s # index name is None but index label is integer 2789s (None, 0, "0"), 2789s ], 2789s ) 2789s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2789s ) 2789s conn = request.getfixturevalue(conn) 2789s > if sql.has_table("test_index_label", conn): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2789s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ____ test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_conn] _____ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn' 2789s request = > 2789s index_name = None, index_label = None, expected = 'index' 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize( 2789s "index_name,index_label,expected", 2789s [ 2789s # no index name, defaults to 'index' 2789s (None, None, "index"), 2789s # specifying index_label 2789s (None, "other_label", "other_label"), 2789s # using the index name 2789s ("index_name", None, "index_name"), 2789s # has index name, but specifying index_label 2789s ("index_name", "other_label", "other_label"), 2789s # index name is integer 2789s (0, None, "0"), 2789s # index name is None but index label is integer 2789s (None, 0, "0"), 2789s ], 2789s ) 2789s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2789s ) 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ test_api_to_sql_index_label[None-other_label-other_label-mysql_pymysql_engine] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2789s request = > 2789s index_name = None, index_label = 'other_label', expected = 'other_label' 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize( 2789s "index_name,index_label,expected", 2789s [ 2789s # no index name, defaults to 'index' 2789s (None, None, "index"), 2789s # specifying index_label 2789s (None, "other_label", "other_label"), 2789s # using the index name 2789s ("index_name", None, "index_name"), 2789s # has index name, but specifying index_label 2789s ("index_name", "other_label", "other_label"), 2789s # index name is integer 2789s (0, None, "0"), 2789s # index name is None but index label is integer 2789s (None, 0, "0"), 2789s ], 2789s ) 2789s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2789s ) 2789s conn = request.getfixturevalue(conn) 2789s > if sql.has_table("test_index_label", conn): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2789s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ test_api_to_sql_index_label[None-other_label-other_label-mysql_pymysql_conn] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn' 2789s request = > 2789s index_name = None, index_label = 'other_label', expected = 'other_label' 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize( 2789s "index_name,index_label,expected", 2789s [ 2789s # no index name, defaults to 'index' 2789s (None, None, "index"), 2789s # specifying index_label 2789s (None, "other_label", "other_label"), 2789s # using the index name 2789s ("index_name", None, "index_name"), 2789s # has index name, but specifying index_label 2789s ("index_name", "other_label", "other_label"), 2789s # index name is integer 2789s (0, None, "0"), 2789s # index name is None but index label is integer 2789s (None, 0, "0"), 2789s ], 2789s ) 2789s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2789s ) 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ test_api_to_sql_index_label[None-other_label-other_label-postgresql_psycopg2_engine] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s request = > 2789s index_name = None, index_label = 'other_label', expected = 'other_label' 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize( 2789s "index_name,index_label,expected", 2789s [ 2789s # no index name, defaults to 'index' 2789s (None, None, "index"), 2789s # specifying index_label 2789s (None, "other_label", "other_label"), 2789s # using the index name 2789s ("index_name", None, "index_name"), 2789s # has index name, but specifying index_label 2789s ("index_name", "other_label", "other_label"), 2789s # index name is integer 2789s (0, None, "0"), 2789s # index name is None but index label is integer 2789s (None, 0, "0"), 2789s ], 2789s ) 2789s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2789s ) 2789s conn = request.getfixturevalue(conn) 2789s > if sql.has_table("test_index_label", conn): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2789s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ test_api_to_sql_index_label[None-other_label-other_label-postgresql_psycopg2_conn] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn' 2789s request = > 2789s index_name = None, index_label = 'other_label', expected = 'other_label' 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize( 2789s "index_name,index_label,expected", 2789s [ 2789s # no index name, defaults to 'index' 2789s (None, None, "index"), 2789s # specifying index_label 2789s (None, "other_label", "other_label"), 2789s # using the index name 2789s ("index_name", None, "index_name"), 2789s # has index name, but specifying index_label 2789s ("index_name", "other_label", "other_label"), 2789s # index name is integer 2789s (0, None, "0"), 2789s # index name is None but index label is integer 2789s (None, 0, "0"), 2789s ], 2789s ) 2789s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2789s ) 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ test_api_to_sql_index_label[index_name-None-index_name-mysql_pymysql_engine] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2789s request = > 2789s index_name = 'index_name', index_label = None, expected = 'index_name' 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize( 2789s "index_name,index_label,expected", 2789s [ 2789s # no index name, defaults to 'index' 2789s (None, None, "index"), 2789s # specifying index_label 2789s (None, "other_label", "other_label"), 2789s # using the index name 2789s ("index_name", None, "index_name"), 2789s # has index name, but specifying index_label 2789s ("index_name", "other_label", "other_label"), 2789s # index name is integer 2789s (0, None, "0"), 2789s # index name is None but index label is integer 2789s (None, 0, "0"), 2789s ], 2789s ) 2789s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2789s ) 2789s conn = request.getfixturevalue(conn) 2789s > if sql.has_table("test_index_label", conn): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2789s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s __ test_api_to_sql_index_label[index_name-None-index_name-mysql_pymysql_conn] __ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn' 2789s request = > 2789s index_name = 'index_name', index_label = None, expected = 'index_name' 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize( 2789s "index_name,index_label,expected", 2789s [ 2789s # no index name, defaults to 'index' 2789s (None, None, "index"), 2789s # specifying index_label 2789s (None, "other_label", "other_label"), 2789s # using the index name 2789s ("index_name", None, "index_name"), 2789s # has index name, but specifying index_label 2789s ("index_name", "other_label", "other_label"), 2789s # index name is integer 2789s (0, None, "0"), 2789s # index name is None but index label is integer 2789s (None, 0, "0"), 2789s ], 2789s ) 2789s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2789s ) 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ test_api_to_sql_index_label[index_name-None-index_name-postgresql_psycopg2_engine] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s request = > 2789s index_name = 'index_name', index_label = None, expected = 'index_name' 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize( 2789s "index_name,index_label,expected", 2789s [ 2789s # no index name, defaults to 'index' 2789s (None, None, "index"), 2789s # specifying index_label 2789s (None, "other_label", "other_label"), 2789s # using the index name 2789s ("index_name", None, "index_name"), 2789s # has index name, but specifying index_label 2789s ("index_name", "other_label", "other_label"), 2789s # index name is integer 2789s (0, None, "0"), 2789s # index name is None but index label is integer 2789s (None, 0, "0"), 2789s ], 2789s ) 2789s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2789s ) 2789s conn = request.getfixturevalue(conn) 2789s > if sql.has_table("test_index_label", conn): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2789s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ test_api_to_sql_index_label[index_name-None-index_name-postgresql_psycopg2_conn] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn' 2789s request = > 2789s index_name = 'index_name', index_label = None, expected = 'index_name' 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize( 2789s "index_name,index_label,expected", 2789s [ 2789s # no index name, defaults to 'index' 2789s (None, None, "index"), 2789s # specifying index_label 2789s (None, "other_label", "other_label"), 2789s # using the index name 2789s ("index_name", None, "index_name"), 2789s # has index name, but specifying index_label 2789s ("index_name", "other_label", "other_label"), 2789s # index name is integer 2789s (0, None, "0"), 2789s # index name is None but index label is integer 2789s (None, 0, "0"), 2789s ], 2789s ) 2789s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2789s ) 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ test_api_to_sql_index_label[index_name-other_label-other_label-mysql_pymysql_engine] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2789s request = > 2789s index_name = 'index_name', index_label = 'other_label', expected = 'other_label' 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize( 2789s "index_name,index_label,expected", 2789s [ 2789s # no index name, defaults to 'index' 2789s (None, None, "index"), 2789s # specifying index_label 2789s (None, "other_label", "other_label"), 2789s # using the index name 2789s ("index_name", None, "index_name"), 2789s # has index name, but specifying index_label 2789s ("index_name", "other_label", "other_label"), 2789s # index name is integer 2789s (0, None, "0"), 2789s # index name is None but index label is integer 2789s (None, 0, "0"), 2789s ], 2789s ) 2789s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2789s ) 2789s conn = request.getfixturevalue(conn) 2789s > if sql.has_table("test_index_label", conn): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2789s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ test_api_to_sql_index_label[index_name-other_label-other_label-mysql_pymysql_conn] _ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn' 2789s request = > 2789s index_name = 'index_name', index_label = 'other_label', expected = 'other_label' 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize( 2789s "index_name,index_label,expected", 2789s [ 2789s # no index name, defaults to 'index' 2789s (None, None, "index"), 2789s # specifying index_label 2789s (None, "other_label", "other_label"), 2789s # using the index name 2789s ("index_name", None, "index_name"), 2789s # has index name, but specifying index_label 2789s ("index_name", "other_label", "other_label"), 2789s # index name is integer 2789s (0, None, "0"), 2789s # index name is None but index label is integer 2789s (None, 0, "0"), 2789s ], 2789s ) 2789s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2789s ) 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _ test_api_to_sql_index_label[index_name-other_label-other_label-postgresql_psycopg2_engine] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s request = > 2789s index_name = 'index_name', index_label = 'other_label', expected = 'other_label' 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize( 2789s "index_name,index_label,expected", 2789s [ 2789s # no index name, defaults to 'index' 2789s (None, None, "index"), 2789s # specifying index_label 2789s (None, "other_label", "other_label"), 2789s # using the index name 2789s ("index_name", None, "index_name"), 2789s # has index name, but specifying index_label 2789s ("index_name", "other_label", "other_label"), 2789s # index name is integer 2789s (0, None, "0"), 2789s # index name is None but index label is integer 2789s (None, 0, "0"), 2789s ], 2789s ) 2789s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2789s ) 2789s conn = request.getfixturevalue(conn) 2789s > if sql.has_table("test_index_label", conn): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2789s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _ test_api_to_sql_index_label[index_name-other_label-other_label-postgresql_psycopg2_conn] _ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn' 2789s request = > 2789s index_name = 'index_name', index_label = 'other_label', expected = 'other_label' 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize( 2789s "index_name,index_label,expected", 2789s [ 2789s # no index name, defaults to 'index' 2789s (None, None, "index"), 2789s # specifying index_label 2789s (None, "other_label", "other_label"), 2789s # using the index name 2789s ("index_name", None, "index_name"), 2789s # has index name, but specifying index_label 2789s ("index_name", "other_label", "other_label"), 2789s # index name is integer 2789s (0, None, "0"), 2789s # index name is None but index label is integer 2789s (None, 0, "0"), 2789s ], 2789s ) 2789s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2789s ) 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s __________ test_api_to_sql_index_label[0-None-0-mysql_pymysql_engine] __________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2789s request = > 2789s index_name = 0, index_label = None, expected = '0' 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize( 2789s "index_name,index_label,expected", 2789s [ 2789s # no index name, defaults to 'index' 2789s (None, None, "index"), 2789s # specifying index_label 2789s (None, "other_label", "other_label"), 2789s # using the index name 2789s ("index_name", None, "index_name"), 2789s # has index name, but specifying index_label 2789s ("index_name", "other_label", "other_label"), 2789s # index name is integer 2789s (0, None, "0"), 2789s # index name is None but index label is integer 2789s (None, 0, "0"), 2789s ], 2789s ) 2789s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2789s ) 2789s conn = request.getfixturevalue(conn) 2789s > if sql.has_table("test_index_label", conn): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2789s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ___________ test_api_to_sql_index_label[0-None-0-mysql_pymysql_conn] ___________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn' 2789s request = > 2789s index_name = 0, index_label = None, expected = '0' 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize( 2789s "index_name,index_label,expected", 2789s [ 2789s # no index name, defaults to 'index' 2789s (None, None, "index"), 2789s # specifying index_label 2789s (None, "other_label", "other_label"), 2789s # using the index name 2789s ("index_name", None, "index_name"), 2789s # has index name, but specifying index_label 2789s ("index_name", "other_label", "other_label"), 2789s # index name is integer 2789s (0, None, "0"), 2789s # index name is None but index label is integer 2789s (None, 0, "0"), 2789s ], 2789s ) 2789s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2789s ) 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _______ test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_engine] _______ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s request = > 2789s index_name = 0, index_label = None, expected = '0' 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize( 2789s "index_name,index_label,expected", 2789s [ 2789s # no index name, defaults to 'index' 2789s (None, None, "index"), 2789s # specifying index_label 2789s (None, "other_label", "other_label"), 2789s # using the index name 2789s ("index_name", None, "index_name"), 2789s # has index name, but specifying index_label 2789s ("index_name", "other_label", "other_label"), 2789s # index name is integer 2789s (0, None, "0"), 2789s # index name is None but index label is integer 2789s (None, 0, "0"), 2789s ], 2789s ) 2789s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2789s ) 2789s conn = request.getfixturevalue(conn) 2789s > if sql.has_table("test_index_label", conn): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2789s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ________ test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_conn] ________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn' 2789s request = > 2789s index_name = 0, index_label = None, expected = '0' 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize( 2789s "index_name,index_label,expected", 2789s [ 2789s # no index name, defaults to 'index' 2789s (None, None, "index"), 2789s # specifying index_label 2789s (None, "other_label", "other_label"), 2789s # using the index name 2789s ("index_name", None, "index_name"), 2789s # has index name, but specifying index_label 2789s ("index_name", "other_label", "other_label"), 2789s # index name is integer 2789s (0, None, "0"), 2789s # index name is None but index label is integer 2789s (None, 0, "0"), 2789s ], 2789s ) 2789s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2789s ) 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s __________ test_api_to_sql_index_label[None-0-0-mysql_pymysql_engine] __________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2789s request = > 2789s index_name = None, index_label = 0, expected = '0' 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize( 2789s "index_name,index_label,expected", 2789s [ 2789s # no index name, defaults to 'index' 2789s (None, None, "index"), 2789s # specifying index_label 2789s (None, "other_label", "other_label"), 2789s # using the index name 2789s ("index_name", None, "index_name"), 2789s # has index name, but specifying index_label 2789s ("index_name", "other_label", "other_label"), 2789s # index name is integer 2789s (0, None, "0"), 2789s # index name is None but index label is integer 2789s (None, 0, "0"), 2789s ], 2789s ) 2789s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2789s ) 2789s conn = request.getfixturevalue(conn) 2789s > if sql.has_table("test_index_label", conn): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2789s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ___________ test_api_to_sql_index_label[None-0-0-mysql_pymysql_conn] ___________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn' 2789s request = > 2789s index_name = None, index_label = 0, expected = '0' 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize( 2789s "index_name,index_label,expected", 2789s [ 2789s # no index name, defaults to 'index' 2789s (None, None, "index"), 2789s # specifying index_label 2789s (None, "other_label", "other_label"), 2789s # using the index name 2789s ("index_name", None, "index_name"), 2789s # has index name, but specifying index_label 2789s ("index_name", "other_label", "other_label"), 2789s # index name is integer 2789s (0, None, "0"), 2789s # index name is None but index label is integer 2789s (None, 0, "0"), 2789s ], 2789s ) 2789s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2789s ) 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _______ test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_engine] _______ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s request = > 2789s index_name = None, index_label = 0, expected = '0' 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize( 2789s "index_name,index_label,expected", 2789s [ 2789s # no index name, defaults to 'index' 2789s (None, None, "index"), 2789s # specifying index_label 2789s (None, "other_label", "other_label"), 2789s # using the index name 2789s ("index_name", None, "index_name"), 2789s # has index name, but specifying index_label 2789s ("index_name", "other_label", "other_label"), 2789s # index name is integer 2789s (0, None, "0"), 2789s # index name is None but index label is integer 2789s (None, 0, "0"), 2789s ], 2789s ) 2789s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2789s ) 2789s conn = request.getfixturevalue(conn) 2789s > if sql.has_table("test_index_label", conn): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2789s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ________ test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_conn] ________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn' 2789s request = > 2789s index_name = None, index_label = 0, expected = '0' 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize( 2789s "index_name,index_label,expected", 2789s [ 2789s # no index name, defaults to 'index' 2789s (None, None, "index"), 2789s # specifying index_label 2789s (None, "other_label", "other_label"), 2789s # using the index name 2789s ("index_name", None, "index_name"), 2789s # has index name, but specifying index_label 2789s ("index_name", "other_label", "other_label"), 2789s # index name is integer 2789s (0, None, "0"), 2789s # index name is None but index label is integer 2789s (None, 0, "0"), 2789s ], 2789s ) 2789s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2789s ) 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ______ test_api_to_sql_index_label_multiindex[postgresql_psycopg2_engine] ______ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_to_sql_index_label_multiindex(conn, request): 2789s conn_name = conn 2789s if "mysql" in conn_name: 2789s request.applymarker( 2789s pytest.mark.xfail( 2789s reason="MySQL can fail using TEXT without length as key", strict=False 2789s ) 2789s ) 2789s elif "adbc" in conn_name: 2789s request.node.add_marker( 2789s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2789s ) 2789s 2789s conn = request.getfixturevalue(conn) 2789s > if sql.has_table("test_index_label", conn): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2004: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2789s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _______ test_api_to_sql_index_label_multiindex[postgresql_psycopg2_conn] _______ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_to_sql_index_label_multiindex(conn, request): 2789s conn_name = conn 2789s if "mysql" in conn_name: 2789s request.applymarker( 2789s pytest.mark.xfail( 2789s reason="MySQL can fail using TEXT without length as key", strict=False 2789s ) 2789s ) 2789s elif "adbc" in conn_name: 2789s request.node.add_marker( 2789s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2789s ) 2789s 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2003: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _____________ test_api_multiindex_roundtrip[mysql_pymysql_engine] ______________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_multiindex_roundtrip(conn, request): 2789s conn = request.getfixturevalue(conn) 2789s > if sql.has_table("test_multiindex_roundtrip", conn): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2066: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2789s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ______________ test_api_multiindex_roundtrip[mysql_pymysql_conn] _______________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_multiindex_roundtrip(conn, request): 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2065: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s __________ test_api_multiindex_roundtrip[postgresql_psycopg2_engine] ___________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_multiindex_roundtrip(conn, request): 2789s conn = request.getfixturevalue(conn) 2789s > if sql.has_table("test_multiindex_roundtrip", conn): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2066: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2789s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ___________ test_api_multiindex_roundtrip[postgresql_psycopg2_conn] ____________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_multiindex_roundtrip(conn, request): 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2065: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ______________ test_api_dtype_argument[None-mysql_pymysql_engine] ______________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2789s request = > 2789s dtype = None 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize( 2789s "dtype", 2789s [ 2789s None, 2789s int, 2789s float, 2789s {"A": int, "B": float}, 2789s ], 2789s ) 2789s def test_api_dtype_argument(conn, request, dtype): 2789s # GH10285 Add dtype argument to read_sql_query 2789s conn_name = conn 2789s conn = request.getfixturevalue(conn) 2789s > if sql.has_table("test_dtype_argument", conn): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2789s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _______________ test_api_dtype_argument[None-mysql_pymysql_conn] _______________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn' 2789s request = > 2789s dtype = None 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize( 2789s "dtype", 2789s [ 2789s None, 2789s int, 2789s float, 2789s {"A": int, "B": float}, 2789s ], 2789s ) 2789s def test_api_dtype_argument(conn, request, dtype): 2789s # GH10285 Add dtype argument to read_sql_query 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ___________ test_api_dtype_argument[None-postgresql_psycopg2_engine] ___________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s request = > 2789s dtype = None 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize( 2789s "dtype", 2789s [ 2789s None, 2789s int, 2789s float, 2789s {"A": int, "B": float}, 2789s ], 2789s ) 2789s def test_api_dtype_argument(conn, request, dtype): 2789s # GH10285 Add dtype argument to read_sql_query 2789s conn_name = conn 2789s conn = request.getfixturevalue(conn) 2789s > if sql.has_table("test_dtype_argument", conn): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2789s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ____________ test_api_dtype_argument[None-postgresql_psycopg2_conn] ____________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn' 2789s request = > 2789s dtype = None 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize( 2789s "dtype", 2789s [ 2789s None, 2789s int, 2789s float, 2789s {"A": int, "B": float}, 2789s ], 2789s ) 2789s def test_api_dtype_argument(conn, request, dtype): 2789s # GH10285 Add dtype argument to read_sql_query 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ______________ test_api_dtype_argument[int-mysql_pymysql_engine] _______________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2789s request = > 2789s dtype = 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize( 2789s "dtype", 2789s [ 2789s None, 2789s int, 2789s float, 2789s {"A": int, "B": float}, 2789s ], 2789s ) 2789s def test_api_dtype_argument(conn, request, dtype): 2789s # GH10285 Add dtype argument to read_sql_query 2789s conn_name = conn 2789s conn = request.getfixturevalue(conn) 2789s > if sql.has_table("test_dtype_argument", conn): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2789s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _______________ test_api_dtype_argument[int-mysql_pymysql_conn] ________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn' 2789s request = > 2789s dtype = 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize( 2789s "dtype", 2789s [ 2789s None, 2789s int, 2789s float, 2789s {"A": int, "B": float}, 2789s ], 2789s ) 2789s def test_api_dtype_argument(conn, request, dtype): 2789s # GH10285 Add dtype argument to read_sql_query 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ___________ test_api_dtype_argument[int-postgresql_psycopg2_engine] ____________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s request = > 2789s dtype = 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize( 2789s "dtype", 2789s [ 2789s None, 2789s int, 2789s float, 2789s {"A": int, "B": float}, 2789s ], 2789s ) 2789s def test_api_dtype_argument(conn, request, dtype): 2789s # GH10285 Add dtype argument to read_sql_query 2789s conn_name = conn 2789s conn = request.getfixturevalue(conn) 2789s > if sql.has_table("test_dtype_argument", conn): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2789s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ____________ test_api_dtype_argument[int-postgresql_psycopg2_conn] _____________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn' 2789s request = > 2789s dtype = 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize( 2789s "dtype", 2789s [ 2789s None, 2789s int, 2789s float, 2789s {"A": int, "B": float}, 2789s ], 2789s ) 2789s def test_api_dtype_argument(conn, request, dtype): 2789s # GH10285 Add dtype argument to read_sql_query 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _____________ test_api_dtype_argument[float-mysql_pymysql_engine] ______________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2789s request = > 2789s dtype = 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize( 2789s "dtype", 2789s [ 2789s None, 2789s int, 2789s float, 2789s {"A": int, "B": float}, 2789s ], 2789s ) 2789s def test_api_dtype_argument(conn, request, dtype): 2789s # GH10285 Add dtype argument to read_sql_query 2789s conn_name = conn 2789s conn = request.getfixturevalue(conn) 2789s > if sql.has_table("test_dtype_argument", conn): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2789s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ______________ test_api_dtype_argument[float-mysql_pymysql_conn] _______________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn' 2789s request = > 2789s dtype = 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize( 2789s "dtype", 2789s [ 2789s None, 2789s int, 2789s float, 2789s {"A": int, "B": float}, 2789s ], 2789s ) 2789s def test_api_dtype_argument(conn, request, dtype): 2789s # GH10285 Add dtype argument to read_sql_query 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s __________ test_api_dtype_argument[float-postgresql_psycopg2_engine] ___________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s request = > 2789s dtype = 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize( 2789s "dtype", 2789s [ 2789s None, 2789s int, 2789s float, 2789s {"A": int, "B": float}, 2789s ], 2789s ) 2789s def test_api_dtype_argument(conn, request, dtype): 2789s # GH10285 Add dtype argument to read_sql_query 2789s conn_name = conn 2789s conn = request.getfixturevalue(conn) 2789s > if sql.has_table("test_dtype_argument", conn): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2789s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ___________ test_api_dtype_argument[float-postgresql_psycopg2_conn] ____________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn' 2789s request = > 2789s dtype = 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize( 2789s "dtype", 2789s [ 2789s None, 2789s int, 2789s float, 2789s {"A": int, "B": float}, 2789s ], 2789s ) 2789s def test_api_dtype_argument(conn, request, dtype): 2789s # GH10285 Add dtype argument to read_sql_query 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _____________ test_api_dtype_argument[dtype3-mysql_pymysql_engine] _____________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2789s request = > 2789s dtype = {'A': , 'B': } 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize( 2789s "dtype", 2789s [ 2789s None, 2789s int, 2789s float, 2789s {"A": int, "B": float}, 2789s ], 2789s ) 2789s def test_api_dtype_argument(conn, request, dtype): 2789s # GH10285 Add dtype argument to read_sql_query 2789s conn_name = conn 2789s conn = request.getfixturevalue(conn) 2789s > if sql.has_table("test_dtype_argument", conn): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2789s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ______________ test_api_dtype_argument[dtype3-mysql_pymysql_conn] ______________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn' 2789s request = > 2789s dtype = {'A': , 'B': } 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize( 2789s "dtype", 2789s [ 2789s None, 2789s int, 2789s float, 2789s {"A": int, "B": float}, 2789s ], 2789s ) 2789s def test_api_dtype_argument(conn, request, dtype): 2789s # GH10285 Add dtype argument to read_sql_query 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s __________ test_api_dtype_argument[dtype3-postgresql_psycopg2_engine] __________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s request = > 2789s dtype = {'A': , 'B': } 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize( 2789s "dtype", 2789s [ 2789s None, 2789s int, 2789s float, 2789s {"A": int, "B": float}, 2789s ], 2789s ) 2789s def test_api_dtype_argument(conn, request, dtype): 2789s # GH10285 Add dtype argument to read_sql_query 2789s conn_name = conn 2789s conn = request.getfixturevalue(conn) 2789s > if sql.has_table("test_dtype_argument", conn): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2789s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ___________ test_api_dtype_argument[dtype3-postgresql_psycopg2_conn] ___________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn' 2789s request = > 2789s dtype = {'A': , 'B': } 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s @pytest.mark.parametrize( 2789s "dtype", 2789s [ 2789s None, 2789s int, 2789s float, 2789s {"A": int, "B": float}, 2789s ], 2789s ) 2789s def test_api_dtype_argument(conn, request, dtype): 2789s # GH10285 Add dtype argument to read_sql_query 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _______________ test_api_integer_col_names[mysql_pymysql_engine] _______________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_integer_col_names(conn, request): 2789s conn = request.getfixturevalue(conn) 2789s df = DataFrame([[1, 2], [3, 4]], columns=[0, 1]) 2789s > sql.to_sql(df, "test_frame_integer_col_names", conn, if_exists="replace") 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2119: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2789s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ________________ test_api_integer_col_names[mysql_pymysql_conn] ________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_integer_col_names(conn, request): 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2117: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ____________ test_api_integer_col_names[postgresql_psycopg2_engine] ____________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_integer_col_names(conn, request): 2789s conn = request.getfixturevalue(conn) 2789s df = DataFrame([[1, 2], [3, 4]], columns=[0, 1]) 2789s > sql.to_sql(df, "test_frame_integer_col_names", conn, if_exists="replace") 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2119: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2789s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _____________ test_api_integer_col_names[postgresql_psycopg2_conn] _____________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_integer_col_names(conn, request): 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2117: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s __________________ test_api_get_schema[mysql_pymysql_engine] ___________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2789s request = > 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_get_schema(conn, request, test_frame1): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="'get_schema' not implemented for ADBC drivers", 2789s strict=True, 2789s ) 2789s ) 2789s conn = request.getfixturevalue(conn) 2789s > create_sql = sql.get_schema(test_frame1, "test", con=conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2132: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 2789s with pandasSQL_builder(con=con) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ___________________ test_api_get_schema[mysql_pymysql_conn] ____________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn' 2789s request = > 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_get_schema(conn, request, test_frame1): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="'get_schema' not implemented for ADBC drivers", 2789s strict=True, 2789s ) 2789s ) 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2131: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _______________ test_api_get_schema[postgresql_psycopg2_engine] ________________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s request = > 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_get_schema(conn, request, test_frame1): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="'get_schema' not implemented for ADBC drivers", 2789s strict=True, 2789s ) 2789s ) 2789s conn = request.getfixturevalue(conn) 2789s > create_sql = sql.get_schema(test_frame1, "test", con=conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2132: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 2789s with pandasSQL_builder(con=con) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ________________ test_api_get_schema[postgresql_psycopg2_conn] _________________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn' 2789s request = > 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_get_schema(conn, request, test_frame1): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="'get_schema' not implemented for ADBC drivers", 2789s strict=True, 2789s ) 2789s ) 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2131: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ____________ test_api_get_schema_with_schema[mysql_pymysql_engine] _____________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2789s request = > 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_get_schema_with_schema(conn, request, test_frame1): 2789s # GH28486 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="'get_schema' not implemented for ADBC drivers", 2789s strict=True, 2789s ) 2789s ) 2789s conn = request.getfixturevalue(conn) 2789s > create_sql = sql.get_schema(test_frame1, "test", con=conn, schema="pypi") 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2147: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 2789s with pandasSQL_builder(con=con) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _____________ test_api_get_schema_with_schema[mysql_pymysql_conn] ______________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn' 2789s request = > 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_get_schema_with_schema(conn, request, test_frame1): 2789s # GH28486 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="'get_schema' not implemented for ADBC drivers", 2789s strict=True, 2789s ) 2789s ) 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _________ test_api_get_schema_with_schema[postgresql_psycopg2_engine] __________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s request = > 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_get_schema_with_schema(conn, request, test_frame1): 2789s # GH28486 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="'get_schema' not implemented for ADBC drivers", 2789s strict=True, 2789s ) 2789s ) 2789s conn = request.getfixturevalue(conn) 2789s > create_sql = sql.get_schema(test_frame1, "test", con=conn, schema="pypi") 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2147: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 2789s with pandasSQL_builder(con=con) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s __________ test_api_get_schema_with_schema[postgresql_psycopg2_conn] ___________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn' 2789s request = > 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_get_schema_with_schema(conn, request, test_frame1): 2789s # GH28486 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="'get_schema' not implemented for ADBC drivers", 2789s strict=True, 2789s ) 2789s ) 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _______________ test_api_get_schema_dtypes[mysql_pymysql_engine] _______________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_get_schema_dtypes(conn, request): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="'get_schema' not implemented for ADBC drivers", 2789s strict=True, 2789s ) 2789s ) 2789s conn_name = conn 2789s conn = request.getfixturevalue(conn) 2789s float_frame = DataFrame({"a": [1.1, 1.2], "b": [2.1, 2.2]}) 2789s 2789s if conn_name == "sqlite_buildin": 2789s dtype = "INTEGER" 2789s else: 2789s from sqlalchemy import Integer 2789s 2789s dtype = Integer 2789s > create_sql = sql.get_schema(float_frame, "test", con=conn, dtype={"b": dtype}) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2170: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 2789s with pandasSQL_builder(con=con) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ________________ test_api_get_schema_dtypes[mysql_pymysql_conn] ________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_get_schema_dtypes(conn, request): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="'get_schema' not implemented for ADBC drivers", 2789s strict=True, 2789s ) 2789s ) 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2161: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ____________ test_api_get_schema_dtypes[postgresql_psycopg2_engine] ____________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_get_schema_dtypes(conn, request): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="'get_schema' not implemented for ADBC drivers", 2789s strict=True, 2789s ) 2789s ) 2789s conn_name = conn 2789s conn = request.getfixturevalue(conn) 2789s float_frame = DataFrame({"a": [1.1, 1.2], "b": [2.1, 2.2]}) 2789s 2789s if conn_name == "sqlite_buildin": 2789s dtype = "INTEGER" 2789s else: 2789s from sqlalchemy import Integer 2789s 2789s dtype = Integer 2789s > create_sql = sql.get_schema(float_frame, "test", con=conn, dtype={"b": dtype}) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2170: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 2789s with pandasSQL_builder(con=con) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _____________ test_api_get_schema_dtypes[postgresql_psycopg2_conn] _____________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_get_schema_dtypes(conn, request): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="'get_schema' not implemented for ADBC drivers", 2789s strict=True, 2789s ) 2789s ) 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2161: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ________________ test_api_get_schema_keys[mysql_pymysql_engine] ________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2789s request = > 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_get_schema_keys(conn, request, test_frame1): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="'get_schema' not implemented for ADBC drivers", 2789s strict=True, 2789s ) 2789s ) 2789s conn_name = conn 2789s conn = request.getfixturevalue(conn) 2789s frame = DataFrame({"Col1": [1.1, 1.2], "Col2": [2.1, 2.2]}) 2789s > create_sql = sql.get_schema(frame, "test", con=conn, keys="Col1") 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2187: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 2789s with pandasSQL_builder(con=con) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _________________ test_api_get_schema_keys[mysql_pymysql_conn] _________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn' 2789s request = > 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_get_schema_keys(conn, request, test_frame1): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="'get_schema' not implemented for ADBC drivers", 2789s strict=True, 2789s ) 2789s ) 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2185: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _____________ test_api_get_schema_keys[postgresql_psycopg2_engine] _____________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s request = > 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_get_schema_keys(conn, request, test_frame1): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="'get_schema' not implemented for ADBC drivers", 2789s strict=True, 2789s ) 2789s ) 2789s conn_name = conn 2789s conn = request.getfixturevalue(conn) 2789s frame = DataFrame({"Col1": [1.1, 1.2], "Col2": [2.1, 2.2]}) 2789s > create_sql = sql.get_schema(frame, "test", con=conn, keys="Col1") 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2187: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 2789s with pandasSQL_builder(con=con) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ______________ test_api_get_schema_keys[postgresql_psycopg2_conn] ______________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn' 2789s request = > 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_get_schema_keys(conn, request, test_frame1): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="'get_schema' not implemented for ADBC drivers", 2789s strict=True, 2789s ) 2789s ) 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2185: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ________________ test_api_chunksize_read[mysql_pymysql_engine] _________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_chunksize_read(conn, request): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2789s ) 2789s conn_name = conn 2789s conn = request.getfixturevalue(conn) 2789s > if sql.has_table("test_chunksize", conn): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2212: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2789s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _________________ test_api_chunksize_read[mysql_pymysql_conn] __________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_chunksize_read(conn, request): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2789s ) 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2211: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _____________ test_api_chunksize_read[postgresql_psycopg2_engine] ______________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_chunksize_read(conn, request): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2789s ) 2789s conn_name = conn 2789s conn = request.getfixturevalue(conn) 2789s > if sql.has_table("test_chunksize", conn): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2212: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2789s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ______________ test_api_chunksize_read[postgresql_psycopg2_conn] _______________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_chunksize_read(conn, request): 2789s if "adbc" in conn: 2789s request.node.add_marker( 2789s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2789s ) 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2211: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s __________________ test_api_categorical[mysql_pymysql_engine] __________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_categorical(conn, request): 2789s if conn == "postgresql_adbc_conn": 2789s adbc = import_optional_dependency("adbc_driver_postgresql", errors="ignore") 2789s if adbc is not None and Version(adbc.__version__) < Version("0.9.0"): 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="categorical dtype not implemented for ADBC postgres driver", 2789s strict=True, 2789s ) 2789s ) 2789s # GH8624 2789s # test that categorical gets written correctly as dense column 2789s conn = request.getfixturevalue(conn) 2789s > if sql.has_table("test_categorical", conn): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2267: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2789s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ___________________ test_api_categorical[mysql_pymysql_conn] ___________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_categorical(conn, request): 2789s if conn == "postgresql_adbc_conn": 2789s adbc = import_optional_dependency("adbc_driver_postgresql", errors="ignore") 2789s if adbc is not None and Version(adbc.__version__) < Version("0.9.0"): 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="categorical dtype not implemented for ADBC postgres driver", 2789s strict=True, 2789s ) 2789s ) 2789s # GH8624 2789s # test that categorical gets written correctly as dense column 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2266: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _______________ test_api_categorical[postgresql_psycopg2_engine] _______________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_categorical(conn, request): 2789s if conn == "postgresql_adbc_conn": 2789s adbc = import_optional_dependency("adbc_driver_postgresql", errors="ignore") 2789s if adbc is not None and Version(adbc.__version__) < Version("0.9.0"): 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="categorical dtype not implemented for ADBC postgres driver", 2789s strict=True, 2789s ) 2789s ) 2789s # GH8624 2789s # test that categorical gets written correctly as dense column 2789s conn = request.getfixturevalue(conn) 2789s > if sql.has_table("test_categorical", conn): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2267: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2789s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ________________ test_api_categorical[postgresql_psycopg2_conn] ________________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_categorical(conn, request): 2789s if conn == "postgresql_adbc_conn": 2789s adbc = import_optional_dependency("adbc_driver_postgresql", errors="ignore") 2789s if adbc is not None and Version(adbc.__version__) < Version("0.9.0"): 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="categorical dtype not implemented for ADBC postgres driver", 2789s strict=True, 2789s ) 2789s ) 2789s # GH8624 2789s # test that categorical gets written correctly as dense column 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2266: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ______________ test_api_unicode_column_name[mysql_pymysql_engine] ______________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_unicode_column_name(conn, request): 2789s # GH 11431 2789s conn = request.getfixturevalue(conn) 2789s > if sql.has_table("test_unicode", conn): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2290: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2789s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _______________ test_api_unicode_column_name[mysql_pymysql_conn] _______________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_unicode_column_name(conn, request): 2789s # GH 11431 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2289: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ___________ test_api_unicode_column_name[postgresql_psycopg2_engine] ___________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_unicode_column_name(conn, request): 2789s # GH 11431 2789s conn = request.getfixturevalue(conn) 2789s > if sql.has_table("test_unicode", conn): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2290: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2789s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ____________ test_api_unicode_column_name[postgresql_psycopg2_conn] ____________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_unicode_column_name(conn, request): 2789s # GH 11431 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2289: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ______________ test_api_escaped_table_name[mysql_pymysql_engine] _______________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_escaped_table_name(conn, request): 2789s # GH 13206 2789s conn_name = conn 2789s conn = request.getfixturevalue(conn) 2789s > if sql.has_table("d1187b08-4943-4c8d-a7f6", conn): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2303: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2789s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _______________ test_api_escaped_table_name[mysql_pymysql_conn] ________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_escaped_table_name(conn, request): 2789s # GH 13206 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2302: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ___________ test_api_escaped_table_name[postgresql_psycopg2_engine] ____________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_escaped_table_name(conn, request): 2789s # GH 13206 2789s conn_name = conn 2789s conn = request.getfixturevalue(conn) 2789s > if sql.has_table("d1187b08-4943-4c8d-a7f6", conn): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2303: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2789s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ____________ test_api_escaped_table_name[postgresql_psycopg2_conn] _____________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_escaped_table_name(conn, request): 2789s # GH 13206 2789s conn_name = conn 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2302: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s __________ test_api_read_sql_duplicate_columns[mysql_pymysql_engine] ___________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_read_sql_duplicate_columns(conn, request): 2789s # GH#53117 2789s if "adbc" in conn: 2789s pa = pytest.importorskip("pyarrow") 2789s if not ( 2789s Version(pa.__version__) >= Version("16.0") 2789s and conn in ["sqlite_adbc_conn", "postgresql_adbc_conn"] 2789s ): 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="pyarrow->pandas throws ValueError", strict=True 2789s ) 2789s ) 2789s conn = request.getfixturevalue(conn) 2789s > if sql.has_table("test_table", conn): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2334: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2789s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ___________ test_api_read_sql_duplicate_columns[mysql_pymysql_conn] ____________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_read_sql_duplicate_columns(conn, request): 2789s # GH#53117 2789s if "adbc" in conn: 2789s pa = pytest.importorskip("pyarrow") 2789s if not ( 2789s Version(pa.__version__) >= Version("16.0") 2789s and conn in ["sqlite_adbc_conn", "postgresql_adbc_conn"] 2789s ): 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="pyarrow->pandas throws ValueError", strict=True 2789s ) 2789s ) 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2333: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _______ test_api_read_sql_duplicate_columns[postgresql_psycopg2_engine] ________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_read_sql_duplicate_columns(conn, request): 2789s # GH#53117 2789s if "adbc" in conn: 2789s pa = pytest.importorskip("pyarrow") 2789s if not ( 2789s Version(pa.__version__) >= Version("16.0") 2789s and conn in ["sqlite_adbc_conn", "postgresql_adbc_conn"] 2789s ): 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="pyarrow->pandas throws ValueError", strict=True 2789s ) 2789s ) 2789s conn = request.getfixturevalue(conn) 2789s > if sql.has_table("test_table", conn): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2334: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2789s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ________ test_api_read_sql_duplicate_columns[postgresql_psycopg2_conn] _________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_api_read_sql_duplicate_columns(conn, request): 2789s # GH#53117 2789s if "adbc" in conn: 2789s pa = pytest.importorskip("pyarrow") 2789s if not ( 2789s Version(pa.__version__) >= Version("16.0") 2789s and conn in ["sqlite_adbc_conn", "postgresql_adbc_conn"] 2789s ): 2789s request.node.add_marker( 2789s pytest.mark.xfail( 2789s reason="pyarrow->pandas throws ValueError", strict=True 2789s ) 2789s ) 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2333: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ________________ test_read_table_columns[mysql_pymysql_engine] _________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2789s request = > 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_read_table_columns(conn, request, test_frame1): 2789s # test columns argument in read_table 2789s conn_name = conn 2789s if conn_name == "sqlite_buildin": 2789s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 2789s 2789s conn = request.getfixturevalue(conn) 2789s > sql.to_sql(test_frame1, "test_frame", conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2357: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2789s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _________________ test_read_table_columns[mysql_pymysql_conn] __________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn' 2789s request = > 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_read_table_columns(conn, request, test_frame1): 2789s # test columns argument in read_table 2789s conn_name = conn 2789s if conn_name == "sqlite_buildin": 2789s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 2789s 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2356: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _____________ test_read_table_columns[postgresql_psycopg2_engine] ______________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s request = > 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_read_table_columns(conn, request, test_frame1): 2789s # test columns argument in read_table 2789s conn_name = conn 2789s if conn_name == "sqlite_buildin": 2789s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 2789s 2789s conn = request.getfixturevalue(conn) 2789s > sql.to_sql(test_frame1, "test_frame", conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2357: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2789s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ______________ test_read_table_columns[postgresql_psycopg2_conn] _______________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn' 2789s request = > 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_read_table_columns(conn, request, test_frame1): 2789s # test columns argument in read_table 2789s conn_name = conn 2789s if conn_name == "sqlite_buildin": 2789s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 2789s 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2356: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _______________ test_read_table_index_col[mysql_pymysql_engine] ________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2789s request = > 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_read_table_index_col(conn, request, test_frame1): 2789s # test columns argument in read_table 2789s conn_name = conn 2789s if conn_name == "sqlite_buildin": 2789s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 2789s 2789s conn = request.getfixturevalue(conn) 2789s > sql.to_sql(test_frame1, "test_frame", conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2373: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2789s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ________________ test_read_table_index_col[mysql_pymysql_conn] _________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn' 2789s request = > 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_read_table_index_col(conn, request, test_frame1): 2789s # test columns argument in read_table 2789s conn_name = conn 2789s if conn_name == "sqlite_buildin": 2789s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 2789s 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2372: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ____________ test_read_table_index_col[postgresql_psycopg2_engine] _____________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s request = > 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_read_table_index_col(conn, request, test_frame1): 2789s # test columns argument in read_table 2789s conn_name = conn 2789s if conn_name == "sqlite_buildin": 2789s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 2789s 2789s conn = request.getfixturevalue(conn) 2789s > sql.to_sql(test_frame1, "test_frame", conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2373: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2789s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2789s return SQLDatabase(con, schema, need_transaction) 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _____________ test_read_table_index_col[postgresql_psycopg2_conn] ______________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn' 2789s request = > 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_read_table_index_col(conn, request, test_frame1): 2789s # test columns argument in read_table 2789s conn_name = conn 2789s if conn_name == "sqlite_buildin": 2789s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 2789s 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2372: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ______________ test_read_sql_delegate[mysql_pymysql_engine_iris] _______________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_engine_iris' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_iris) 2789s def test_read_sql_delegate(conn, request): 2789s if conn == "sqlite_buildin_iris": 2789s request.applymarker( 2789s pytest.mark.xfail( 2789s reason="sqlite_buildin connection does not implement read_sql_table" 2789s ) 2789s ) 2789s 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2397: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2789s create_and_load_iris(mysql_pymysql_engine, iris_path) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2789s with conn.begin() as con: 2789s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2789s return next(self.gen) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2789s with self.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _______________ test_read_sql_delegate[mysql_pymysql_conn_iris] ________________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn_iris' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_iris) 2789s def test_read_sql_delegate(conn, request): 2789s if conn == "sqlite_buildin_iris": 2789s request.applymarker( 2789s pytest.mark.xfail( 2789s reason="sqlite_buildin connection does not implement read_sql_table" 2789s ) 2789s ) 2789s 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2397: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2789s create_and_load_iris(mysql_pymysql_engine, iris_path) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2789s with conn.begin() as con: 2789s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2789s return next(self.gen) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2789s with self.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ___________ test_read_sql_delegate[postgresql_psycopg2_engine_iris] ____________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_engine_iris' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_iris) 2789s def test_read_sql_delegate(conn, request): 2789s if conn == "sqlite_buildin_iris": 2789s request.applymarker( 2789s pytest.mark.xfail( 2789s reason="sqlite_buildin connection does not implement read_sql_table" 2789s ) 2789s ) 2789s 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2397: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2789s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2789s with conn.begin() as con: 2789s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2789s return next(self.gen) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2789s with self.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ____________ test_read_sql_delegate[postgresql_psycopg2_conn_iris] _____________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn_iris' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", all_connectable_iris) 2789s def test_read_sql_delegate(conn, request): 2789s if conn == "sqlite_buildin_iris": 2789s request.applymarker( 2789s pytest.mark.xfail( 2789s reason="sqlite_buildin connection does not implement read_sql_table" 2789s ) 2789s ) 2789s 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2397: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2789s fixturedef = request._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2789s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2789s with conn.begin() as con: 2789s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2789s return next(self.gen) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2789s with self.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ________ test_warning_case_insensitive_table_name[mysql_pymysql_engine] ________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2789s request = > 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_warning_case_insensitive_table_name(conn, request, test_frame1): 2789s conn_name = conn 2789s if conn_name == "sqlite_buildin" or "adbc" in conn_name: 2789s request.applymarker(pytest.mark.xfail(reason="Does not raise warning")) 2789s 2789s conn = request.getfixturevalue(conn) 2789s # see gh-7815 2789s with tm.assert_produces_warning( 2789s UserWarning, 2789s match=( 2789s r"The provided table name 'TABLE1' is not found exactly as such in " 2789s r"the database after writing the table, possibly due to case " 2789s r"sensitivity issues. Consider using lower case table names." 2789s ), 2789s ): 2789s > with sql.SQLDatabase(conn) as db: 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2448: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2789s request = > 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_warning_case_insensitive_table_name(conn, request, test_frame1): 2789s conn_name = conn 2789s if conn_name == "sqlite_buildin" or "adbc" in conn_name: 2789s request.applymarker(pytest.mark.xfail(reason="Does not raise warning")) 2789s 2789s conn = request.getfixturevalue(conn) 2789s # see gh-7815 2789s > with tm.assert_produces_warning( 2789s UserWarning, 2789s match=( 2789s r"The provided table name 'TABLE1' is not found exactly as such in " 2789s r"the database after writing the table, possibly due to case " 2789s r"sensitivity issues. Consider using lower case table names." 2789s ), 2789s ): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2440: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/contextlib.py:162: in __exit__ 2789s self.gen.throw(value) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s def _assert_caught_expected_warning( 2789s *, 2789s caught_warnings: Sequence[warnings.WarningMessage], 2789s expected_warning: type[Warning], 2789s match: str | None, 2789s check_stacklevel: bool, 2789s ) -> None: 2789s """Assert that there was the expected warning among the caught warnings.""" 2789s saw_warning = False 2789s matched_message = False 2789s unmatched_messages = [] 2789s 2789s for actual_warning in caught_warnings: 2789s if issubclass(actual_warning.category, expected_warning): 2789s saw_warning = True 2789s 2789s if check_stacklevel: 2789s _assert_raised_with_correct_stacklevel(actual_warning) 2789s 2789s if match is not None: 2789s if re.search(match, str(actual_warning.message)): 2789s matched_message = True 2789s else: 2789s unmatched_messages.append(actual_warning.message) 2789s 2789s if not saw_warning: 2789s > raise AssertionError( 2789s f"Did not see expected warning of class " 2789s f"{repr(expected_warning.__name__)}" 2789s ) 2789s E AssertionError: Did not see expected warning of class 'UserWarning' 2789s 2789s /usr/lib/python3/dist-packages/pandas/_testing/_warnings.py:152: AssertionError 2789s _________ test_warning_case_insensitive_table_name[mysql_pymysql_conn] _________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn' 2789s request = > 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_warning_case_insensitive_table_name(conn, request, test_frame1): 2789s conn_name = conn 2789s if conn_name == "sqlite_buildin" or "adbc" in conn_name: 2789s request.applymarker(pytest.mark.xfail(reason="Does not raise warning")) 2789s 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2438: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _____ test_warning_case_insensitive_table_name[postgresql_psycopg2_engine] _____ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s request = > 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_warning_case_insensitive_table_name(conn, request, test_frame1): 2789s conn_name = conn 2789s if conn_name == "sqlite_buildin" or "adbc" in conn_name: 2789s request.applymarker(pytest.mark.xfail(reason="Does not raise warning")) 2789s 2789s conn = request.getfixturevalue(conn) 2789s # see gh-7815 2789s with tm.assert_produces_warning( 2789s UserWarning, 2789s match=( 2789s r"The provided table name 'TABLE1' is not found exactly as such in " 2789s r"the database after writing the table, possibly due to case " 2789s r"sensitivity issues. Consider using lower case table names." 2789s ), 2789s ): 2789s > with sql.SQLDatabase(conn) as db: 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2448: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s request = > 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_warning_case_insensitive_table_name(conn, request, test_frame1): 2789s conn_name = conn 2789s if conn_name == "sqlite_buildin" or "adbc" in conn_name: 2789s request.applymarker(pytest.mark.xfail(reason="Does not raise warning")) 2789s 2789s conn = request.getfixturevalue(conn) 2789s # see gh-7815 2789s > with tm.assert_produces_warning( 2789s UserWarning, 2789s match=( 2789s r"The provided table name 'TABLE1' is not found exactly as such in " 2789s r"the database after writing the table, possibly due to case " 2789s r"sensitivity issues. Consider using lower case table names." 2789s ), 2789s ): 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2440: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/contextlib.py:162: in __exit__ 2789s self.gen.throw(value) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s def _assert_caught_expected_warning( 2789s *, 2789s caught_warnings: Sequence[warnings.WarningMessage], 2789s expected_warning: type[Warning], 2789s match: str | None, 2789s check_stacklevel: bool, 2789s ) -> None: 2789s """Assert that there was the expected warning among the caught warnings.""" 2789s saw_warning = False 2789s matched_message = False 2789s unmatched_messages = [] 2789s 2789s for actual_warning in caught_warnings: 2789s if issubclass(actual_warning.category, expected_warning): 2789s saw_warning = True 2789s 2789s if check_stacklevel: 2789s _assert_raised_with_correct_stacklevel(actual_warning) 2789s 2789s if match is not None: 2789s if re.search(match, str(actual_warning.message)): 2789s matched_message = True 2789s else: 2789s unmatched_messages.append(actual_warning.message) 2789s 2789s if not saw_warning: 2789s > raise AssertionError( 2789s f"Did not see expected warning of class " 2789s f"{repr(expected_warning.__name__)}" 2789s ) 2789s E AssertionError: Did not see expected warning of class 'UserWarning' 2789s 2789s /usr/lib/python3/dist-packages/pandas/_testing/_warnings.py:152: AssertionError 2789s ______ test_warning_case_insensitive_table_name[postgresql_psycopg2_conn] ______ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn' 2789s request = > 2789s test_frame1 = index A B C D 2789s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2789s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2789s 2789s @pytest.mark.parametrize("conn", all_connectable) 2789s def test_warning_case_insensitive_table_name(conn, request, test_frame1): 2789s conn_name = conn 2789s if conn_name == "sqlite_buildin" or "adbc" in conn_name: 2789s request.applymarker(pytest.mark.xfail(reason="Does not raise warning")) 2789s 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2438: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ______________ test_sqlalchemy_type_mapping[mysql_pymysql_engine] ______________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2789s def test_sqlalchemy_type_mapping(conn, request): 2789s conn = request.getfixturevalue(conn) 2789s from sqlalchemy import TIMESTAMP 2789s 2789s # Test Timestamp objects (no datetime64 because of timezone) (GH9085) 2789s df = DataFrame( 2789s {"time": to_datetime(["2014-12-12 01:54", "2014-12-11 02:54"], utc=True)} 2789s ) 2789s > with sql.SQLDatabase(conn) as db: 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2465: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s _______________ test_sqlalchemy_type_mapping[mysql_pymysql_conn] _______________ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2789s def test_sqlalchemy_type_mapping(conn, request): 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2458: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ___________ test_sqlalchemy_type_mapping[postgresql_psycopg2_engine] ___________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2789s def test_sqlalchemy_type_mapping(conn, request): 2789s conn = request.getfixturevalue(conn) 2789s from sqlalchemy import TIMESTAMP 2789s 2789s # Test Timestamp objects (no datetime64 because of timezone) (GH9085) 2789s df = DataFrame( 2789s {"time": to_datetime(["2014-12-12 01:54", "2014-12-11 02:54"], utc=True)} 2789s ) 2789s > with sql.SQLDatabase(conn) as db: 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2465: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ____________ test_sqlalchemy_type_mapping[postgresql_psycopg2_conn] ____________ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn' 2789s request = > 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2789s def test_sqlalchemy_type_mapping(conn, request): 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2458: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _____ test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_engine] ______ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2789s request = > 2789s integer = 'int8', expected = 'SMALLINT' 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2789s @pytest.mark.parametrize( 2789s "integer, expected", 2789s [ 2789s ("int8", "SMALLINT"), 2789s ("Int8", "SMALLINT"), 2789s ("uint8", "SMALLINT"), 2789s ("UInt8", "SMALLINT"), 2789s ("int16", "SMALLINT"), 2789s ("Int16", "SMALLINT"), 2789s ("uint16", "INTEGER"), 2789s ("UInt16", "INTEGER"), 2789s ("int32", "INTEGER"), 2789s ("Int32", "INTEGER"), 2789s ("uint32", "BIGINT"), 2789s ("UInt32", "BIGINT"), 2789s ("int64", "BIGINT"), 2789s ("Int64", "BIGINT"), 2789s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2789s ], 2789s ) 2789s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2789s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2789s conn = request.getfixturevalue(conn) 2789s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2789s > with sql.SQLDatabase(conn) as db: 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ______ test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_conn] _______ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn' 2789s request = > 2789s integer = 'int8', expected = 'SMALLINT' 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2789s @pytest.mark.parametrize( 2789s "integer, expected", 2789s [ 2789s ("int8", "SMALLINT"), 2789s ("Int8", "SMALLINT"), 2789s ("uint8", "SMALLINT"), 2789s ("UInt8", "SMALLINT"), 2789s ("int16", "SMALLINT"), 2789s ("Int16", "SMALLINT"), 2789s ("uint16", "INTEGER"), 2789s ("UInt16", "INTEGER"), 2789s ("int32", "INTEGER"), 2789s ("Int32", "INTEGER"), 2789s ("uint32", "BIGINT"), 2789s ("UInt32", "BIGINT"), 2789s ("int64", "BIGINT"), 2789s ("Int64", "BIGINT"), 2789s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2789s ], 2789s ) 2789s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2789s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s __ test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_engine] ___ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s request = > 2789s integer = 'int8', expected = 'SMALLINT' 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2789s @pytest.mark.parametrize( 2789s "integer, expected", 2789s [ 2789s ("int8", "SMALLINT"), 2789s ("Int8", "SMALLINT"), 2789s ("uint8", "SMALLINT"), 2789s ("UInt8", "SMALLINT"), 2789s ("int16", "SMALLINT"), 2789s ("Int16", "SMALLINT"), 2789s ("uint16", "INTEGER"), 2789s ("UInt16", "INTEGER"), 2789s ("int32", "INTEGER"), 2789s ("Int32", "INTEGER"), 2789s ("uint32", "BIGINT"), 2789s ("UInt32", "BIGINT"), 2789s ("int64", "BIGINT"), 2789s ("Int64", "BIGINT"), 2789s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2789s ], 2789s ) 2789s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2789s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2789s conn = request.getfixturevalue(conn) 2789s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2789s > with sql.SQLDatabase(conn) as db: 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ___ test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_conn] ____ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn' 2789s request = > 2789s integer = 'int8', expected = 'SMALLINT' 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2789s @pytest.mark.parametrize( 2789s "integer, expected", 2789s [ 2789s ("int8", "SMALLINT"), 2789s ("Int8", "SMALLINT"), 2789s ("uint8", "SMALLINT"), 2789s ("UInt8", "SMALLINT"), 2789s ("int16", "SMALLINT"), 2789s ("Int16", "SMALLINT"), 2789s ("uint16", "INTEGER"), 2789s ("UInt16", "INTEGER"), 2789s ("int32", "INTEGER"), 2789s ("Int32", "INTEGER"), 2789s ("uint32", "BIGINT"), 2789s ("UInt32", "BIGINT"), 2789s ("int64", "BIGINT"), 2789s ("Int64", "BIGINT"), 2789s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2789s ], 2789s ) 2789s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2789s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _____ test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_engine] ______ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2789s request = > 2789s integer = 'Int8', expected = 'SMALLINT' 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2789s @pytest.mark.parametrize( 2789s "integer, expected", 2789s [ 2789s ("int8", "SMALLINT"), 2789s ("Int8", "SMALLINT"), 2789s ("uint8", "SMALLINT"), 2789s ("UInt8", "SMALLINT"), 2789s ("int16", "SMALLINT"), 2789s ("Int16", "SMALLINT"), 2789s ("uint16", "INTEGER"), 2789s ("UInt16", "INTEGER"), 2789s ("int32", "INTEGER"), 2789s ("Int32", "INTEGER"), 2789s ("uint32", "BIGINT"), 2789s ("UInt32", "BIGINT"), 2789s ("int64", "BIGINT"), 2789s ("Int64", "BIGINT"), 2789s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2789s ], 2789s ) 2789s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2789s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2789s conn = request.getfixturevalue(conn) 2789s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2789s > with sql.SQLDatabase(conn) as db: 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ______ test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_conn] _______ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn' 2789s request = > 2789s integer = 'Int8', expected = 'SMALLINT' 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2789s @pytest.mark.parametrize( 2789s "integer, expected", 2789s [ 2789s ("int8", "SMALLINT"), 2789s ("Int8", "SMALLINT"), 2789s ("uint8", "SMALLINT"), 2789s ("UInt8", "SMALLINT"), 2789s ("int16", "SMALLINT"), 2789s ("Int16", "SMALLINT"), 2789s ("uint16", "INTEGER"), 2789s ("UInt16", "INTEGER"), 2789s ("int32", "INTEGER"), 2789s ("Int32", "INTEGER"), 2789s ("uint32", "BIGINT"), 2789s ("UInt32", "BIGINT"), 2789s ("int64", "BIGINT"), 2789s ("Int64", "BIGINT"), 2789s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2789s ], 2789s ) 2789s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2789s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s __ test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_engine] ___ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s request = > 2789s integer = 'Int8', expected = 'SMALLINT' 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2789s @pytest.mark.parametrize( 2789s "integer, expected", 2789s [ 2789s ("int8", "SMALLINT"), 2789s ("Int8", "SMALLINT"), 2789s ("uint8", "SMALLINT"), 2789s ("UInt8", "SMALLINT"), 2789s ("int16", "SMALLINT"), 2789s ("Int16", "SMALLINT"), 2789s ("uint16", "INTEGER"), 2789s ("UInt16", "INTEGER"), 2789s ("int32", "INTEGER"), 2789s ("Int32", "INTEGER"), 2789s ("uint32", "BIGINT"), 2789s ("UInt32", "BIGINT"), 2789s ("int64", "BIGINT"), 2789s ("Int64", "BIGINT"), 2789s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2789s ], 2789s ) 2789s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2789s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2789s conn = request.getfixturevalue(conn) 2789s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2789s > with sql.SQLDatabase(conn) as db: 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ___ test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_conn] ____ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn' 2789s request = > 2789s integer = 'Int8', expected = 'SMALLINT' 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2789s @pytest.mark.parametrize( 2789s "integer, expected", 2789s [ 2789s ("int8", "SMALLINT"), 2789s ("Int8", "SMALLINT"), 2789s ("uint8", "SMALLINT"), 2789s ("UInt8", "SMALLINT"), 2789s ("int16", "SMALLINT"), 2789s ("Int16", "SMALLINT"), 2789s ("uint16", "INTEGER"), 2789s ("UInt16", "INTEGER"), 2789s ("int32", "INTEGER"), 2789s ("Int32", "INTEGER"), 2789s ("uint32", "BIGINT"), 2789s ("UInt32", "BIGINT"), 2789s ("int64", "BIGINT"), 2789s ("Int64", "BIGINT"), 2789s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2789s ], 2789s ) 2789s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2789s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _____ test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_engine] _____ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2789s request = > 2789s integer = 'uint8', expected = 'SMALLINT' 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2789s @pytest.mark.parametrize( 2789s "integer, expected", 2789s [ 2789s ("int8", "SMALLINT"), 2789s ("Int8", "SMALLINT"), 2789s ("uint8", "SMALLINT"), 2789s ("UInt8", "SMALLINT"), 2789s ("int16", "SMALLINT"), 2789s ("Int16", "SMALLINT"), 2789s ("uint16", "INTEGER"), 2789s ("UInt16", "INTEGER"), 2789s ("int32", "INTEGER"), 2789s ("Int32", "INTEGER"), 2789s ("uint32", "BIGINT"), 2789s ("UInt32", "BIGINT"), 2789s ("int64", "BIGINT"), 2789s ("Int64", "BIGINT"), 2789s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2789s ], 2789s ) 2789s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2789s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2789s conn = request.getfixturevalue(conn) 2789s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2789s > with sql.SQLDatabase(conn) as db: 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ______ test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_conn] ______ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn' 2789s request = > 2789s integer = 'uint8', expected = 'SMALLINT' 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2789s @pytest.mark.parametrize( 2789s "integer, expected", 2789s [ 2789s ("int8", "SMALLINT"), 2789s ("Int8", "SMALLINT"), 2789s ("uint8", "SMALLINT"), 2789s ("UInt8", "SMALLINT"), 2789s ("int16", "SMALLINT"), 2789s ("Int16", "SMALLINT"), 2789s ("uint16", "INTEGER"), 2789s ("UInt16", "INTEGER"), 2789s ("int32", "INTEGER"), 2789s ("Int32", "INTEGER"), 2789s ("uint32", "BIGINT"), 2789s ("UInt32", "BIGINT"), 2789s ("int64", "BIGINT"), 2789s ("Int64", "BIGINT"), 2789s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2789s ], 2789s ) 2789s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2789s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s __ test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_engine] __ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s request = > 2789s integer = 'uint8', expected = 'SMALLINT' 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2789s @pytest.mark.parametrize( 2789s "integer, expected", 2789s [ 2789s ("int8", "SMALLINT"), 2789s ("Int8", "SMALLINT"), 2789s ("uint8", "SMALLINT"), 2789s ("UInt8", "SMALLINT"), 2789s ("int16", "SMALLINT"), 2789s ("Int16", "SMALLINT"), 2789s ("uint16", "INTEGER"), 2789s ("UInt16", "INTEGER"), 2789s ("int32", "INTEGER"), 2789s ("Int32", "INTEGER"), 2789s ("uint32", "BIGINT"), 2789s ("UInt32", "BIGINT"), 2789s ("int64", "BIGINT"), 2789s ("Int64", "BIGINT"), 2789s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2789s ], 2789s ) 2789s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2789s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2789s conn = request.getfixturevalue(conn) 2789s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2789s > with sql.SQLDatabase(conn) as db: 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ___ test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_conn] ___ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn' 2789s request = > 2789s integer = 'uint8', expected = 'SMALLINT' 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2789s @pytest.mark.parametrize( 2789s "integer, expected", 2789s [ 2789s ("int8", "SMALLINT"), 2789s ("Int8", "SMALLINT"), 2789s ("uint8", "SMALLINT"), 2789s ("UInt8", "SMALLINT"), 2789s ("int16", "SMALLINT"), 2789s ("Int16", "SMALLINT"), 2789s ("uint16", "INTEGER"), 2789s ("UInt16", "INTEGER"), 2789s ("int32", "INTEGER"), 2789s ("Int32", "INTEGER"), 2789s ("uint32", "BIGINT"), 2789s ("UInt32", "BIGINT"), 2789s ("int64", "BIGINT"), 2789s ("Int64", "BIGINT"), 2789s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2789s ], 2789s ) 2789s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2789s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _____ test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_engine] _____ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2789s request = > 2789s integer = 'UInt8', expected = 'SMALLINT' 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2789s @pytest.mark.parametrize( 2789s "integer, expected", 2789s [ 2789s ("int8", "SMALLINT"), 2789s ("Int8", "SMALLINT"), 2789s ("uint8", "SMALLINT"), 2789s ("UInt8", "SMALLINT"), 2789s ("int16", "SMALLINT"), 2789s ("Int16", "SMALLINT"), 2789s ("uint16", "INTEGER"), 2789s ("UInt16", "INTEGER"), 2789s ("int32", "INTEGER"), 2789s ("Int32", "INTEGER"), 2789s ("uint32", "BIGINT"), 2789s ("UInt32", "BIGINT"), 2789s ("int64", "BIGINT"), 2789s ("Int64", "BIGINT"), 2789s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2789s ], 2789s ) 2789s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2789s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2789s conn = request.getfixturevalue(conn) 2789s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2789s > with sql.SQLDatabase(conn) as db: 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ______ test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_conn] ______ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn' 2789s request = > 2789s integer = 'UInt8', expected = 'SMALLINT' 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2789s @pytest.mark.parametrize( 2789s "integer, expected", 2789s [ 2789s ("int8", "SMALLINT"), 2789s ("Int8", "SMALLINT"), 2789s ("uint8", "SMALLINT"), 2789s ("UInt8", "SMALLINT"), 2789s ("int16", "SMALLINT"), 2789s ("Int16", "SMALLINT"), 2789s ("uint16", "INTEGER"), 2789s ("UInt16", "INTEGER"), 2789s ("int32", "INTEGER"), 2789s ("Int32", "INTEGER"), 2789s ("uint32", "BIGINT"), 2789s ("UInt32", "BIGINT"), 2789s ("int64", "BIGINT"), 2789s ("Int64", "BIGINT"), 2789s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2789s ], 2789s ) 2789s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2789s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s __ test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_engine] __ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s request = > 2789s integer = 'UInt8', expected = 'SMALLINT' 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2789s @pytest.mark.parametrize( 2789s "integer, expected", 2789s [ 2789s ("int8", "SMALLINT"), 2789s ("Int8", "SMALLINT"), 2789s ("uint8", "SMALLINT"), 2789s ("UInt8", "SMALLINT"), 2789s ("int16", "SMALLINT"), 2789s ("Int16", "SMALLINT"), 2789s ("uint16", "INTEGER"), 2789s ("UInt16", "INTEGER"), 2789s ("int32", "INTEGER"), 2789s ("Int32", "INTEGER"), 2789s ("uint32", "BIGINT"), 2789s ("UInt32", "BIGINT"), 2789s ("int64", "BIGINT"), 2789s ("Int64", "BIGINT"), 2789s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2789s ], 2789s ) 2789s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2789s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2789s conn = request.getfixturevalue(conn) 2789s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2789s > with sql.SQLDatabase(conn) as db: 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ___ test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_conn] ___ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn' 2789s request = > 2789s integer = 'UInt8', expected = 'SMALLINT' 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2789s @pytest.mark.parametrize( 2789s "integer, expected", 2789s [ 2789s ("int8", "SMALLINT"), 2789s ("Int8", "SMALLINT"), 2789s ("uint8", "SMALLINT"), 2789s ("UInt8", "SMALLINT"), 2789s ("int16", "SMALLINT"), 2789s ("Int16", "SMALLINT"), 2789s ("uint16", "INTEGER"), 2789s ("UInt16", "INTEGER"), 2789s ("int32", "INTEGER"), 2789s ("Int32", "INTEGER"), 2789s ("uint32", "BIGINT"), 2789s ("UInt32", "BIGINT"), 2789s ("int64", "BIGINT"), 2789s ("Int64", "BIGINT"), 2789s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2789s ], 2789s ) 2789s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2789s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _____ test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_engine] _____ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2789s request = > 2789s integer = 'int16', expected = 'SMALLINT' 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2789s @pytest.mark.parametrize( 2789s "integer, expected", 2789s [ 2789s ("int8", "SMALLINT"), 2789s ("Int8", "SMALLINT"), 2789s ("uint8", "SMALLINT"), 2789s ("UInt8", "SMALLINT"), 2789s ("int16", "SMALLINT"), 2789s ("Int16", "SMALLINT"), 2789s ("uint16", "INTEGER"), 2789s ("UInt16", "INTEGER"), 2789s ("int32", "INTEGER"), 2789s ("Int32", "INTEGER"), 2789s ("uint32", "BIGINT"), 2789s ("UInt32", "BIGINT"), 2789s ("int64", "BIGINT"), 2789s ("Int64", "BIGINT"), 2789s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2789s ], 2789s ) 2789s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2789s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2789s conn = request.getfixturevalue(conn) 2789s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2789s > with sql.SQLDatabase(conn) as db: 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ______ test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_conn] ______ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn' 2789s request = > 2789s integer = 'int16', expected = 'SMALLINT' 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2789s @pytest.mark.parametrize( 2789s "integer, expected", 2789s [ 2789s ("int8", "SMALLINT"), 2789s ("Int8", "SMALLINT"), 2789s ("uint8", "SMALLINT"), 2789s ("UInt8", "SMALLINT"), 2789s ("int16", "SMALLINT"), 2789s ("Int16", "SMALLINT"), 2789s ("uint16", "INTEGER"), 2789s ("UInt16", "INTEGER"), 2789s ("int32", "INTEGER"), 2789s ("Int32", "INTEGER"), 2789s ("uint32", "BIGINT"), 2789s ("UInt32", "BIGINT"), 2789s ("int64", "BIGINT"), 2789s ("Int64", "BIGINT"), 2789s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2789s ], 2789s ) 2789s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2789s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s __ test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_engine] __ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s request = > 2789s integer = 'int16', expected = 'SMALLINT' 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2789s @pytest.mark.parametrize( 2789s "integer, expected", 2789s [ 2789s ("int8", "SMALLINT"), 2789s ("Int8", "SMALLINT"), 2789s ("uint8", "SMALLINT"), 2789s ("UInt8", "SMALLINT"), 2789s ("int16", "SMALLINT"), 2789s ("Int16", "SMALLINT"), 2789s ("uint16", "INTEGER"), 2789s ("UInt16", "INTEGER"), 2789s ("int32", "INTEGER"), 2789s ("Int32", "INTEGER"), 2789s ("uint32", "BIGINT"), 2789s ("UInt32", "BIGINT"), 2789s ("int64", "BIGINT"), 2789s ("Int64", "BIGINT"), 2789s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2789s ], 2789s ) 2789s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2789s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2789s conn = request.getfixturevalue(conn) 2789s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2789s > with sql.SQLDatabase(conn) as db: 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ___ test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_conn] ___ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn' 2789s request = > 2789s integer = 'int16', expected = 'SMALLINT' 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2789s @pytest.mark.parametrize( 2789s "integer, expected", 2789s [ 2789s ("int8", "SMALLINT"), 2789s ("Int8", "SMALLINT"), 2789s ("uint8", "SMALLINT"), 2789s ("UInt8", "SMALLINT"), 2789s ("int16", "SMALLINT"), 2789s ("Int16", "SMALLINT"), 2789s ("uint16", "INTEGER"), 2789s ("UInt16", "INTEGER"), 2789s ("int32", "INTEGER"), 2789s ("Int32", "INTEGER"), 2789s ("uint32", "BIGINT"), 2789s ("UInt32", "BIGINT"), 2789s ("int64", "BIGINT"), 2789s ("Int64", "BIGINT"), 2789s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2789s ], 2789s ) 2789s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2789s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _____ test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_engine] _____ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2789s request = > 2789s integer = 'Int16', expected = 'SMALLINT' 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2789s @pytest.mark.parametrize( 2789s "integer, expected", 2789s [ 2789s ("int8", "SMALLINT"), 2789s ("Int8", "SMALLINT"), 2789s ("uint8", "SMALLINT"), 2789s ("UInt8", "SMALLINT"), 2789s ("int16", "SMALLINT"), 2789s ("Int16", "SMALLINT"), 2789s ("uint16", "INTEGER"), 2789s ("UInt16", "INTEGER"), 2789s ("int32", "INTEGER"), 2789s ("Int32", "INTEGER"), 2789s ("uint32", "BIGINT"), 2789s ("UInt32", "BIGINT"), 2789s ("int64", "BIGINT"), 2789s ("Int64", "BIGINT"), 2789s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2789s ], 2789s ) 2789s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2789s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2789s conn = request.getfixturevalue(conn) 2789s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2789s > with sql.SQLDatabase(conn) as db: 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ______ test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_conn] ______ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn' 2789s request = > 2789s integer = 'Int16', expected = 'SMALLINT' 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2789s @pytest.mark.parametrize( 2789s "integer, expected", 2789s [ 2789s ("int8", "SMALLINT"), 2789s ("Int8", "SMALLINT"), 2789s ("uint8", "SMALLINT"), 2789s ("UInt8", "SMALLINT"), 2789s ("int16", "SMALLINT"), 2789s ("Int16", "SMALLINT"), 2789s ("uint16", "INTEGER"), 2789s ("UInt16", "INTEGER"), 2789s ("int32", "INTEGER"), 2789s ("Int32", "INTEGER"), 2789s ("uint32", "BIGINT"), 2789s ("UInt32", "BIGINT"), 2789s ("int64", "BIGINT"), 2789s ("Int64", "BIGINT"), 2789s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2789s ], 2789s ) 2789s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2789s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s __ test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_engine] __ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s request = > 2789s integer = 'Int16', expected = 'SMALLINT' 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2789s @pytest.mark.parametrize( 2789s "integer, expected", 2789s [ 2789s ("int8", "SMALLINT"), 2789s ("Int8", "SMALLINT"), 2789s ("uint8", "SMALLINT"), 2789s ("UInt8", "SMALLINT"), 2789s ("int16", "SMALLINT"), 2789s ("Int16", "SMALLINT"), 2789s ("uint16", "INTEGER"), 2789s ("UInt16", "INTEGER"), 2789s ("int32", "INTEGER"), 2789s ("Int32", "INTEGER"), 2789s ("uint32", "BIGINT"), 2789s ("UInt32", "BIGINT"), 2789s ("int64", "BIGINT"), 2789s ("Int64", "BIGINT"), 2789s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2789s ], 2789s ) 2789s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2789s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2789s conn = request.getfixturevalue(conn) 2789s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2789s > with sql.SQLDatabase(conn) as db: 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ___ test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_conn] ___ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn' 2789s request = > 2789s integer = 'Int16', expected = 'SMALLINT' 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2789s @pytest.mark.parametrize( 2789s "integer, expected", 2789s [ 2789s ("int8", "SMALLINT"), 2789s ("Int8", "SMALLINT"), 2789s ("uint8", "SMALLINT"), 2789s ("UInt8", "SMALLINT"), 2789s ("int16", "SMALLINT"), 2789s ("Int16", "SMALLINT"), 2789s ("uint16", "INTEGER"), 2789s ("UInt16", "INTEGER"), 2789s ("int32", "INTEGER"), 2789s ("Int32", "INTEGER"), 2789s ("uint32", "BIGINT"), 2789s ("UInt32", "BIGINT"), 2789s ("int64", "BIGINT"), 2789s ("Int64", "BIGINT"), 2789s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2789s ], 2789s ) 2789s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2789s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _____ test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_engine] _____ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2789s request = > 2789s integer = 'uint16', expected = 'INTEGER' 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2789s @pytest.mark.parametrize( 2789s "integer, expected", 2789s [ 2789s ("int8", "SMALLINT"), 2789s ("Int8", "SMALLINT"), 2789s ("uint8", "SMALLINT"), 2789s ("UInt8", "SMALLINT"), 2789s ("int16", "SMALLINT"), 2789s ("Int16", "SMALLINT"), 2789s ("uint16", "INTEGER"), 2789s ("UInt16", "INTEGER"), 2789s ("int32", "INTEGER"), 2789s ("Int32", "INTEGER"), 2789s ("uint32", "BIGINT"), 2789s ("UInt32", "BIGINT"), 2789s ("int64", "BIGINT"), 2789s ("Int64", "BIGINT"), 2789s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2789s ], 2789s ) 2789s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2789s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2789s conn = request.getfixturevalue(conn) 2789s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2789s > with sql.SQLDatabase(conn) as db: 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ______ test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_conn] ______ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn' 2789s request = > 2789s integer = 'uint16', expected = 'INTEGER' 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2789s @pytest.mark.parametrize( 2789s "integer, expected", 2789s [ 2789s ("int8", "SMALLINT"), 2789s ("Int8", "SMALLINT"), 2789s ("uint8", "SMALLINT"), 2789s ("UInt8", "SMALLINT"), 2789s ("int16", "SMALLINT"), 2789s ("Int16", "SMALLINT"), 2789s ("uint16", "INTEGER"), 2789s ("UInt16", "INTEGER"), 2789s ("int32", "INTEGER"), 2789s ("Int32", "INTEGER"), 2789s ("uint32", "BIGINT"), 2789s ("UInt32", "BIGINT"), 2789s ("int64", "BIGINT"), 2789s ("Int64", "BIGINT"), 2789s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2789s ], 2789s ) 2789s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2789s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s __ test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_engine] __ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s request = > 2789s integer = 'uint16', expected = 'INTEGER' 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2789s @pytest.mark.parametrize( 2789s "integer, expected", 2789s [ 2789s ("int8", "SMALLINT"), 2789s ("Int8", "SMALLINT"), 2789s ("uint8", "SMALLINT"), 2789s ("UInt8", "SMALLINT"), 2789s ("int16", "SMALLINT"), 2789s ("Int16", "SMALLINT"), 2789s ("uint16", "INTEGER"), 2789s ("UInt16", "INTEGER"), 2789s ("int32", "INTEGER"), 2789s ("Int32", "INTEGER"), 2789s ("uint32", "BIGINT"), 2789s ("UInt32", "BIGINT"), 2789s ("int64", "BIGINT"), 2789s ("Int64", "BIGINT"), 2789s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2789s ], 2789s ) 2789s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2789s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2789s conn = request.getfixturevalue(conn) 2789s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2789s > with sql.SQLDatabase(conn) as db: 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ___ test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_conn] ___ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn' 2789s request = > 2789s integer = 'uint16', expected = 'INTEGER' 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2789s @pytest.mark.parametrize( 2789s "integer, expected", 2789s [ 2789s ("int8", "SMALLINT"), 2789s ("Int8", "SMALLINT"), 2789s ("uint8", "SMALLINT"), 2789s ("UInt8", "SMALLINT"), 2789s ("int16", "SMALLINT"), 2789s ("Int16", "SMALLINT"), 2789s ("uint16", "INTEGER"), 2789s ("UInt16", "INTEGER"), 2789s ("int32", "INTEGER"), 2789s ("Int32", "INTEGER"), 2789s ("uint32", "BIGINT"), 2789s ("UInt32", "BIGINT"), 2789s ("int64", "BIGINT"), 2789s ("Int64", "BIGINT"), 2789s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2789s ], 2789s ) 2789s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2789s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _____ test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_engine] _____ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2789s request = > 2789s integer = 'UInt16', expected = 'INTEGER' 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2789s @pytest.mark.parametrize( 2789s "integer, expected", 2789s [ 2789s ("int8", "SMALLINT"), 2789s ("Int8", "SMALLINT"), 2789s ("uint8", "SMALLINT"), 2789s ("UInt8", "SMALLINT"), 2789s ("int16", "SMALLINT"), 2789s ("Int16", "SMALLINT"), 2789s ("uint16", "INTEGER"), 2789s ("UInt16", "INTEGER"), 2789s ("int32", "INTEGER"), 2789s ("Int32", "INTEGER"), 2789s ("uint32", "BIGINT"), 2789s ("UInt32", "BIGINT"), 2789s ("int64", "BIGINT"), 2789s ("Int64", "BIGINT"), 2789s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2789s ], 2789s ) 2789s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2789s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2789s conn = request.getfixturevalue(conn) 2789s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2789s > with sql.SQLDatabase(conn) as db: 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ______ test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_conn] ______ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn' 2789s request = > 2789s integer = 'UInt16', expected = 'INTEGER' 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2789s @pytest.mark.parametrize( 2789s "integer, expected", 2789s [ 2789s ("int8", "SMALLINT"), 2789s ("Int8", "SMALLINT"), 2789s ("uint8", "SMALLINT"), 2789s ("UInt8", "SMALLINT"), 2789s ("int16", "SMALLINT"), 2789s ("Int16", "SMALLINT"), 2789s ("uint16", "INTEGER"), 2789s ("UInt16", "INTEGER"), 2789s ("int32", "INTEGER"), 2789s ("Int32", "INTEGER"), 2789s ("uint32", "BIGINT"), 2789s ("UInt32", "BIGINT"), 2789s ("int64", "BIGINT"), 2789s ("Int64", "BIGINT"), 2789s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2789s ], 2789s ) 2789s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2789s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s __ test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_engine] __ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s request = > 2789s integer = 'UInt16', expected = 'INTEGER' 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2789s @pytest.mark.parametrize( 2789s "integer, expected", 2789s [ 2789s ("int8", "SMALLINT"), 2789s ("Int8", "SMALLINT"), 2789s ("uint8", "SMALLINT"), 2789s ("UInt8", "SMALLINT"), 2789s ("int16", "SMALLINT"), 2789s ("Int16", "SMALLINT"), 2789s ("uint16", "INTEGER"), 2789s ("UInt16", "INTEGER"), 2789s ("int32", "INTEGER"), 2789s ("Int32", "INTEGER"), 2789s ("uint32", "BIGINT"), 2789s ("UInt32", "BIGINT"), 2789s ("int64", "BIGINT"), 2789s ("Int64", "BIGINT"), 2789s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2789s ], 2789s ) 2789s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2789s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2789s conn = request.getfixturevalue(conn) 2789s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2789s > with sql.SQLDatabase(conn) as db: 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s ___ test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_conn] ___ 2789s self = 2789s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2789s connection = None, _has_events = None, _allow_revalidate = True 2789s _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'postgresql_psycopg2_conn' 2789s request = > 2789s integer = 'UInt16', expected = 'INTEGER' 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2789s @pytest.mark.parametrize( 2789s "integer, expected", 2789s [ 2789s ("int8", "SMALLINT"), 2789s ("Int8", "SMALLINT"), 2789s ("uint8", "SMALLINT"), 2789s ("UInt8", "SMALLINT"), 2789s ("int16", "SMALLINT"), 2789s ("Int16", "SMALLINT"), 2789s ("uint16", "INTEGER"), 2789s ("UInt16", "INTEGER"), 2789s ("int32", "INTEGER"), 2789s ("Int32", "INTEGER"), 2789s ("uint32", "BIGINT"), 2789s ("UInt32", "BIGINT"), 2789s ("int64", "BIGINT"), 2789s ("Int64", "BIGINT"), 2789s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2789s ], 2789s ) 2789s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2789s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2789s with postgresql_psycopg2_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2789s connection_factory = None, cursor_factory = None 2789s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2789s kwasync = {} 2789s 2789s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2789s """ 2789s Create a new database connection. 2789s 2789s The connection parameters can be specified as a string: 2789s 2789s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2789s 2789s or using a set of keyword arguments: 2789s 2789s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2789s 2789s Or as a mix of both. The basic connection parameters are: 2789s 2789s - *dbname*: the database name 2789s - *database*: the database name (only as keyword argument) 2789s - *user*: user name used to authenticate 2789s - *password*: password used to authenticate 2789s - *host*: database host address (defaults to UNIX socket if not provided) 2789s - *port*: connection port number (defaults to 5432 if not provided) 2789s 2789s Using the *connection_factory* parameter a different class or connections 2789s factory can be specified. It should be a callable object taking a dsn 2789s argument. 2789s 2789s Using the *cursor_factory* parameter, a new default cursor factory will be 2789s used by cursor(). 2789s 2789s Using *async*=True an asynchronous connection will be created. *async_* is 2789s a valid alias (for Python versions where ``async`` is a keyword). 2789s 2789s Any other keyword parameter will be passed to the underlying client 2789s library: the list of supported parameters depends on the library version. 2789s 2789s """ 2789s kwasync = {} 2789s if 'async' in kwargs: 2789s kwasync['async'] = kwargs.pop('async') 2789s if 'async_' in kwargs: 2789s kwasync['async_'] = kwargs.pop('async_') 2789s 2789s dsn = _ext.make_dsn(dsn, **kwargs) 2789s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2789s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2789s E Is the server running on that host and accepting TCP/IP connections? 2789s E 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2789s _____ test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_engine] ______ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2789s request = > 2789s integer = 'int32', expected = 'INTEGER' 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2789s @pytest.mark.parametrize( 2789s "integer, expected", 2789s [ 2789s ("int8", "SMALLINT"), 2789s ("Int8", "SMALLINT"), 2789s ("uint8", "SMALLINT"), 2789s ("UInt8", "SMALLINT"), 2789s ("int16", "SMALLINT"), 2789s ("Int16", "SMALLINT"), 2789s ("uint16", "INTEGER"), 2789s ("UInt16", "INTEGER"), 2789s ("int32", "INTEGER"), 2789s ("Int32", "INTEGER"), 2789s ("uint32", "BIGINT"), 2789s ("UInt32", "BIGINT"), 2789s ("int64", "BIGINT"), 2789s ("Int64", "BIGINT"), 2789s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2789s ], 2789s ) 2789s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2789s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2789s conn = request.getfixturevalue(conn) 2789s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2789s > with sql.SQLDatabase(conn) as db: 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2789s con = self.exit_stack.enter_context(con.connect()) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s ______ test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_conn] _______ 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s > sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3.13/socket.py:864: in create_connection 2789s raise exceptions[0] 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s address = ('localhost', 3306), timeout = 10, source_address = None 2789s 2789s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2789s source_address=None, *, all_errors=False): 2789s """Connect to *address* and return the socket object. 2789s 2789s Convenience function. Connect to *address* (a 2-tuple ``(host, 2789s port)``) and return the socket object. Passing the optional 2789s *timeout* parameter will set the timeout on the socket instance 2789s before attempting to connect. If no *timeout* is supplied, the 2789s global default timeout setting returned by :func:`getdefaulttimeout` 2789s is used. If *source_address* is set it must be a tuple of (host, port) 2789s for the socket to bind as a source address before making the connection. 2789s A host of '' or port 0 tells the OS to use the default. When a connection 2789s cannot be created, raises the last error if *all_errors* is False, 2789s and an ExceptionGroup of all errors if *all_errors* is True. 2789s """ 2789s 2789s host, port = address 2789s exceptions = [] 2789s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2789s af, socktype, proto, canonname, sa = res 2789s sock = None 2789s try: 2789s sock = socket(af, socktype, proto) 2789s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2789s sock.settimeout(timeout) 2789s if source_address: 2789s sock.bind(source_address) 2789s > sock.connect(sa) 2789s E ConnectionRefusedError: [Errno 111] Connection refused 2789s 2789s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2789s 2789s During handling of the above exception, another exception occurred: 2789s 2789s self = 2789s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2789s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2789s 2789s def __init__( 2789s self, 2789s engine: Engine, 2789s connection: Optional[PoolProxiedConnection] = None, 2789s _has_events: Optional[bool] = None, 2789s _allow_revalidate: bool = True, 2789s _allow_autobegin: bool = True, 2789s ): 2789s """Construct a new Connection.""" 2789s self.engine = engine 2789s self.dialect = dialect = engine.dialect 2789s 2789s if connection is None: 2789s try: 2789s > self._dbapi_connection = engine.raw_connection() 2789s 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2789s self.host_info = "Localhost via UNIX socket" 2789s self._secure = True 2789s if DEBUG: 2789s print("connected using unix_socket") 2789s else: 2789s kwargs = {} 2789s if self.bind_address is not None: 2789s kwargs["source_address"] = (self.bind_address, 0) 2789s while True: 2789s try: 2789s sock = socket.create_connection( 2789s (self.host, self.port), self.connect_timeout, **kwargs 2789s ) 2789s break 2789s except OSError as e: 2789s if e.errno == errno.EINTR: 2789s continue 2789s raise 2789s self.host_info = "socket %s:%d" % (self.host, self.port) 2789s if DEBUG: 2789s print("connected using socket") 2789s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2789s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2789s sock.settimeout(None) 2789s 2789s self._sock = sock 2789s self._rfile = sock.makefile("rb") 2789s self._next_seq_id = 0 2789s 2789s self._get_server_information() 2789s self._request_authentication() 2789s 2789s # Send "SET NAMES" query on init for: 2789s # - Ensure charaset (and collation) is set to the server. 2789s # - collation_id in handshake packet may be ignored. 2789s # - If collation is not specified, we don't know what is server's 2789s # default collation for the charset. For example, default collation 2789s # of utf8mb4 is: 2789s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2789s # - MySQL 8.0: utf8mb4_0900_ai_ci 2789s # 2789s # Reference: 2789s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2789s # - https://github.com/wagtail/wagtail/issues/9477 2789s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2789s self.set_character_set(self.charset, self.collation) 2789s 2789s if self.sql_mode is not None: 2789s c = self.cursor() 2789s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2789s c.close() 2789s 2789s if self.init_command is not None: 2789s c = self.cursor() 2789s c.execute(self.init_command) 2789s c.close() 2789s 2789s if self.autocommit_mode is not None: 2789s self.autocommit(self.autocommit_mode) 2789s except BaseException as e: 2789s self._rfile = None 2789s if sock is not None: 2789s try: 2789s sock.close() 2789s except: # noqa 2789s pass 2789s 2789s if isinstance(e, (OSError, IOError)): 2789s exc = err.OperationalError( 2789s CR.CR_CONN_HOST_ERROR, 2789s f"Can't connect to MySQL server on {self.host!r} ({e})", 2789s ) 2789s # Keep original exception and traceback to investigate error. 2789s exc.original_exception = e 2789s exc.traceback = traceback.format_exc() 2789s if DEBUG: 2789s print(exc.traceback) 2789s > raise exc 2789s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2789s 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2789s 2789s The above exception was the direct cause of the following exception: 2789s 2789s conn = 'mysql_pymysql_conn' 2789s request = > 2789s integer = 'int32', expected = 'INTEGER' 2789s 2789s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2789s @pytest.mark.parametrize( 2789s "integer, expected", 2789s [ 2789s ("int8", "SMALLINT"), 2789s ("Int8", "SMALLINT"), 2789s ("uint8", "SMALLINT"), 2789s ("UInt8", "SMALLINT"), 2789s ("int16", "SMALLINT"), 2789s ("Int16", "SMALLINT"), 2789s ("uint16", "INTEGER"), 2789s ("UInt16", "INTEGER"), 2789s ("int32", "INTEGER"), 2789s ("Int32", "INTEGER"), 2789s ("uint32", "BIGINT"), 2789s ("UInt32", "BIGINT"), 2789s ("int64", "BIGINT"), 2789s ("Int64", "BIGINT"), 2789s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2789s ], 2789s ) 2789s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2789s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2789s > conn = request.getfixturevalue(conn) 2789s 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2789s fixturedef = self._get_active_fixturedef(argname) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2789s fixturedef.execute(request=subrequest) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2789s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2789s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2789s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2789s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2789s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2789s return (yield) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2789s result = call_fixture_func(fixturefunc, request, kwargs) 2789s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2789s fixture_result = next(generator) 2789s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2789s with mysql_pymysql_engine.connect() as conn: 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2789s return self._connection_cls(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2789s Connection._handle_dbapi_exception_noconnection( 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2789s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2789s self._dbapi_connection = engine.raw_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2789s return self.pool.connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2789s return _ConnectionFairy._checkout(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2789s fairy = _ConnectionRecord.checkout(pool) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2789s rec = pool._do_get() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2789s return self._create_connection() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2789s return _ConnectionRecord(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2789s self.__connect() 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2789s with util.safe_reraise(): 2789s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2789s raise exc_value.with_traceback(exc_tb) 2789s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2789s self.dbapi_connection = connection = pool._invoke_creator(self) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2789s return dialect.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2789s return self.loaded_dbapi.connect(*cargs, **cparams) 2789s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2789s self.connect() 2789s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2789s 2789s self = , sock = None 2789s 2789s def connect(self, sock=None): 2789s self._closed = False 2789s try: 2789s if sock is None: 2789s if self.unix_socket: 2789s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2789s sock.settimeout(self.connect_timeout) 2789s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s __ test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_engine] ___ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s integer = 'int32', expected = 'INTEGER' 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s @pytest.mark.parametrize( 2790s "integer, expected", 2790s [ 2790s ("int8", "SMALLINT"), 2790s ("Int8", "SMALLINT"), 2790s ("uint8", "SMALLINT"), 2790s ("UInt8", "SMALLINT"), 2790s ("int16", "SMALLINT"), 2790s ("Int16", "SMALLINT"), 2790s ("uint16", "INTEGER"), 2790s ("UInt16", "INTEGER"), 2790s ("int32", "INTEGER"), 2790s ("Int32", "INTEGER"), 2790s ("uint32", "BIGINT"), 2790s ("UInt32", "BIGINT"), 2790s ("int64", "BIGINT"), 2790s ("Int64", "BIGINT"), 2790s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2790s ], 2790s ) 2790s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2790s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2790s conn = request.getfixturevalue(conn) 2790s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2790s > with sql.SQLDatabase(conn) as db: 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ___ test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_conn] ____ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s integer = 'int32', expected = 'INTEGER' 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s @pytest.mark.parametrize( 2790s "integer, expected", 2790s [ 2790s ("int8", "SMALLINT"), 2790s ("Int8", "SMALLINT"), 2790s ("uint8", "SMALLINT"), 2790s ("UInt8", "SMALLINT"), 2790s ("int16", "SMALLINT"), 2790s ("Int16", "SMALLINT"), 2790s ("uint16", "INTEGER"), 2790s ("UInt16", "INTEGER"), 2790s ("int32", "INTEGER"), 2790s ("Int32", "INTEGER"), 2790s ("uint32", "BIGINT"), 2790s ("UInt32", "BIGINT"), 2790s ("int64", "BIGINT"), 2790s ("Int64", "BIGINT"), 2790s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2790s ], 2790s ) 2790s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2790s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _____ test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_engine] ______ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s integer = 'Int32', expected = 'INTEGER' 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s @pytest.mark.parametrize( 2790s "integer, expected", 2790s [ 2790s ("int8", "SMALLINT"), 2790s ("Int8", "SMALLINT"), 2790s ("uint8", "SMALLINT"), 2790s ("UInt8", "SMALLINT"), 2790s ("int16", "SMALLINT"), 2790s ("Int16", "SMALLINT"), 2790s ("uint16", "INTEGER"), 2790s ("UInt16", "INTEGER"), 2790s ("int32", "INTEGER"), 2790s ("Int32", "INTEGER"), 2790s ("uint32", "BIGINT"), 2790s ("UInt32", "BIGINT"), 2790s ("int64", "BIGINT"), 2790s ("Int64", "BIGINT"), 2790s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2790s ], 2790s ) 2790s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2790s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2790s conn = request.getfixturevalue(conn) 2790s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2790s > with sql.SQLDatabase(conn) as db: 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ______ test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_conn] _______ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s integer = 'Int32', expected = 'INTEGER' 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s @pytest.mark.parametrize( 2790s "integer, expected", 2790s [ 2790s ("int8", "SMALLINT"), 2790s ("Int8", "SMALLINT"), 2790s ("uint8", "SMALLINT"), 2790s ("UInt8", "SMALLINT"), 2790s ("int16", "SMALLINT"), 2790s ("Int16", "SMALLINT"), 2790s ("uint16", "INTEGER"), 2790s ("UInt16", "INTEGER"), 2790s ("int32", "INTEGER"), 2790s ("Int32", "INTEGER"), 2790s ("uint32", "BIGINT"), 2790s ("UInt32", "BIGINT"), 2790s ("int64", "BIGINT"), 2790s ("Int64", "BIGINT"), 2790s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2790s ], 2790s ) 2790s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2790s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s __ test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_engine] ___ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s integer = 'Int32', expected = 'INTEGER' 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s @pytest.mark.parametrize( 2790s "integer, expected", 2790s [ 2790s ("int8", "SMALLINT"), 2790s ("Int8", "SMALLINT"), 2790s ("uint8", "SMALLINT"), 2790s ("UInt8", "SMALLINT"), 2790s ("int16", "SMALLINT"), 2790s ("Int16", "SMALLINT"), 2790s ("uint16", "INTEGER"), 2790s ("UInt16", "INTEGER"), 2790s ("int32", "INTEGER"), 2790s ("Int32", "INTEGER"), 2790s ("uint32", "BIGINT"), 2790s ("UInt32", "BIGINT"), 2790s ("int64", "BIGINT"), 2790s ("Int64", "BIGINT"), 2790s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2790s ], 2790s ) 2790s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2790s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2790s conn = request.getfixturevalue(conn) 2790s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2790s > with sql.SQLDatabase(conn) as db: 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ___ test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_conn] ____ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s integer = 'Int32', expected = 'INTEGER' 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s @pytest.mark.parametrize( 2790s "integer, expected", 2790s [ 2790s ("int8", "SMALLINT"), 2790s ("Int8", "SMALLINT"), 2790s ("uint8", "SMALLINT"), 2790s ("UInt8", "SMALLINT"), 2790s ("int16", "SMALLINT"), 2790s ("Int16", "SMALLINT"), 2790s ("uint16", "INTEGER"), 2790s ("UInt16", "INTEGER"), 2790s ("int32", "INTEGER"), 2790s ("Int32", "INTEGER"), 2790s ("uint32", "BIGINT"), 2790s ("UInt32", "BIGINT"), 2790s ("int64", "BIGINT"), 2790s ("Int64", "BIGINT"), 2790s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2790s ], 2790s ) 2790s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2790s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _____ test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_engine] ______ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s integer = 'uint32', expected = 'BIGINT' 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s @pytest.mark.parametrize( 2790s "integer, expected", 2790s [ 2790s ("int8", "SMALLINT"), 2790s ("Int8", "SMALLINT"), 2790s ("uint8", "SMALLINT"), 2790s ("UInt8", "SMALLINT"), 2790s ("int16", "SMALLINT"), 2790s ("Int16", "SMALLINT"), 2790s ("uint16", "INTEGER"), 2790s ("UInt16", "INTEGER"), 2790s ("int32", "INTEGER"), 2790s ("Int32", "INTEGER"), 2790s ("uint32", "BIGINT"), 2790s ("UInt32", "BIGINT"), 2790s ("int64", "BIGINT"), 2790s ("Int64", "BIGINT"), 2790s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2790s ], 2790s ) 2790s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2790s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2790s conn = request.getfixturevalue(conn) 2790s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2790s > with sql.SQLDatabase(conn) as db: 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ______ test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_conn] _______ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s integer = 'uint32', expected = 'BIGINT' 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s @pytest.mark.parametrize( 2790s "integer, expected", 2790s [ 2790s ("int8", "SMALLINT"), 2790s ("Int8", "SMALLINT"), 2790s ("uint8", "SMALLINT"), 2790s ("UInt8", "SMALLINT"), 2790s ("int16", "SMALLINT"), 2790s ("Int16", "SMALLINT"), 2790s ("uint16", "INTEGER"), 2790s ("UInt16", "INTEGER"), 2790s ("int32", "INTEGER"), 2790s ("Int32", "INTEGER"), 2790s ("uint32", "BIGINT"), 2790s ("UInt32", "BIGINT"), 2790s ("int64", "BIGINT"), 2790s ("Int64", "BIGINT"), 2790s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2790s ], 2790s ) 2790s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2790s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s __ test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_engine] ___ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s integer = 'uint32', expected = 'BIGINT' 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s @pytest.mark.parametrize( 2790s "integer, expected", 2790s [ 2790s ("int8", "SMALLINT"), 2790s ("Int8", "SMALLINT"), 2790s ("uint8", "SMALLINT"), 2790s ("UInt8", "SMALLINT"), 2790s ("int16", "SMALLINT"), 2790s ("Int16", "SMALLINT"), 2790s ("uint16", "INTEGER"), 2790s ("UInt16", "INTEGER"), 2790s ("int32", "INTEGER"), 2790s ("Int32", "INTEGER"), 2790s ("uint32", "BIGINT"), 2790s ("UInt32", "BIGINT"), 2790s ("int64", "BIGINT"), 2790s ("Int64", "BIGINT"), 2790s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2790s ], 2790s ) 2790s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2790s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2790s conn = request.getfixturevalue(conn) 2790s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2790s > with sql.SQLDatabase(conn) as db: 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ___ test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_conn] ____ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s integer = 'uint32', expected = 'BIGINT' 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s @pytest.mark.parametrize( 2790s "integer, expected", 2790s [ 2790s ("int8", "SMALLINT"), 2790s ("Int8", "SMALLINT"), 2790s ("uint8", "SMALLINT"), 2790s ("UInt8", "SMALLINT"), 2790s ("int16", "SMALLINT"), 2790s ("Int16", "SMALLINT"), 2790s ("uint16", "INTEGER"), 2790s ("UInt16", "INTEGER"), 2790s ("int32", "INTEGER"), 2790s ("Int32", "INTEGER"), 2790s ("uint32", "BIGINT"), 2790s ("UInt32", "BIGINT"), 2790s ("int64", "BIGINT"), 2790s ("Int64", "BIGINT"), 2790s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2790s ], 2790s ) 2790s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2790s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _____ test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_engine] ______ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s integer = 'UInt32', expected = 'BIGINT' 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s @pytest.mark.parametrize( 2790s "integer, expected", 2790s [ 2790s ("int8", "SMALLINT"), 2790s ("Int8", "SMALLINT"), 2790s ("uint8", "SMALLINT"), 2790s ("UInt8", "SMALLINT"), 2790s ("int16", "SMALLINT"), 2790s ("Int16", "SMALLINT"), 2790s ("uint16", "INTEGER"), 2790s ("UInt16", "INTEGER"), 2790s ("int32", "INTEGER"), 2790s ("Int32", "INTEGER"), 2790s ("uint32", "BIGINT"), 2790s ("UInt32", "BIGINT"), 2790s ("int64", "BIGINT"), 2790s ("Int64", "BIGINT"), 2790s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2790s ], 2790s ) 2790s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2790s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2790s conn = request.getfixturevalue(conn) 2790s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2790s > with sql.SQLDatabase(conn) as db: 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ______ test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_conn] _______ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s integer = 'UInt32', expected = 'BIGINT' 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s @pytest.mark.parametrize( 2790s "integer, expected", 2790s [ 2790s ("int8", "SMALLINT"), 2790s ("Int8", "SMALLINT"), 2790s ("uint8", "SMALLINT"), 2790s ("UInt8", "SMALLINT"), 2790s ("int16", "SMALLINT"), 2790s ("Int16", "SMALLINT"), 2790s ("uint16", "INTEGER"), 2790s ("UInt16", "INTEGER"), 2790s ("int32", "INTEGER"), 2790s ("Int32", "INTEGER"), 2790s ("uint32", "BIGINT"), 2790s ("UInt32", "BIGINT"), 2790s ("int64", "BIGINT"), 2790s ("Int64", "BIGINT"), 2790s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2790s ], 2790s ) 2790s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2790s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s __ test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_engine] ___ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s integer = 'UInt32', expected = 'BIGINT' 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s @pytest.mark.parametrize( 2790s "integer, expected", 2790s [ 2790s ("int8", "SMALLINT"), 2790s ("Int8", "SMALLINT"), 2790s ("uint8", "SMALLINT"), 2790s ("UInt8", "SMALLINT"), 2790s ("int16", "SMALLINT"), 2790s ("Int16", "SMALLINT"), 2790s ("uint16", "INTEGER"), 2790s ("UInt16", "INTEGER"), 2790s ("int32", "INTEGER"), 2790s ("Int32", "INTEGER"), 2790s ("uint32", "BIGINT"), 2790s ("UInt32", "BIGINT"), 2790s ("int64", "BIGINT"), 2790s ("Int64", "BIGINT"), 2790s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2790s ], 2790s ) 2790s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2790s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2790s conn = request.getfixturevalue(conn) 2790s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2790s > with sql.SQLDatabase(conn) as db: 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ___ test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_conn] ____ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s integer = 'UInt32', expected = 'BIGINT' 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s @pytest.mark.parametrize( 2790s "integer, expected", 2790s [ 2790s ("int8", "SMALLINT"), 2790s ("Int8", "SMALLINT"), 2790s ("uint8", "SMALLINT"), 2790s ("UInt8", "SMALLINT"), 2790s ("int16", "SMALLINT"), 2790s ("Int16", "SMALLINT"), 2790s ("uint16", "INTEGER"), 2790s ("UInt16", "INTEGER"), 2790s ("int32", "INTEGER"), 2790s ("Int32", "INTEGER"), 2790s ("uint32", "BIGINT"), 2790s ("UInt32", "BIGINT"), 2790s ("int64", "BIGINT"), 2790s ("Int64", "BIGINT"), 2790s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2790s ], 2790s ) 2790s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2790s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ______ test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_engine] ______ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s integer = 'int64', expected = 'BIGINT' 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s @pytest.mark.parametrize( 2790s "integer, expected", 2790s [ 2790s ("int8", "SMALLINT"), 2790s ("Int8", "SMALLINT"), 2790s ("uint8", "SMALLINT"), 2790s ("UInt8", "SMALLINT"), 2790s ("int16", "SMALLINT"), 2790s ("Int16", "SMALLINT"), 2790s ("uint16", "INTEGER"), 2790s ("UInt16", "INTEGER"), 2790s ("int32", "INTEGER"), 2790s ("Int32", "INTEGER"), 2790s ("uint32", "BIGINT"), 2790s ("UInt32", "BIGINT"), 2790s ("int64", "BIGINT"), 2790s ("Int64", "BIGINT"), 2790s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2790s ], 2790s ) 2790s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2790s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2790s conn = request.getfixturevalue(conn) 2790s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2790s > with sql.SQLDatabase(conn) as db: 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _______ test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_conn] _______ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s integer = 'int64', expected = 'BIGINT' 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s @pytest.mark.parametrize( 2790s "integer, expected", 2790s [ 2790s ("int8", "SMALLINT"), 2790s ("Int8", "SMALLINT"), 2790s ("uint8", "SMALLINT"), 2790s ("UInt8", "SMALLINT"), 2790s ("int16", "SMALLINT"), 2790s ("Int16", "SMALLINT"), 2790s ("uint16", "INTEGER"), 2790s ("UInt16", "INTEGER"), 2790s ("int32", "INTEGER"), 2790s ("Int32", "INTEGER"), 2790s ("uint32", "BIGINT"), 2790s ("UInt32", "BIGINT"), 2790s ("int64", "BIGINT"), 2790s ("Int64", "BIGINT"), 2790s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2790s ], 2790s ) 2790s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2790s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ___ test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_engine] ___ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s integer = 'int64', expected = 'BIGINT' 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s @pytest.mark.parametrize( 2790s "integer, expected", 2790s [ 2790s ("int8", "SMALLINT"), 2790s ("Int8", "SMALLINT"), 2790s ("uint8", "SMALLINT"), 2790s ("UInt8", "SMALLINT"), 2790s ("int16", "SMALLINT"), 2790s ("Int16", "SMALLINT"), 2790s ("uint16", "INTEGER"), 2790s ("UInt16", "INTEGER"), 2790s ("int32", "INTEGER"), 2790s ("Int32", "INTEGER"), 2790s ("uint32", "BIGINT"), 2790s ("UInt32", "BIGINT"), 2790s ("int64", "BIGINT"), 2790s ("Int64", "BIGINT"), 2790s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2790s ], 2790s ) 2790s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2790s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2790s conn = request.getfixturevalue(conn) 2790s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2790s > with sql.SQLDatabase(conn) as db: 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ____ test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_conn] ____ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s integer = 'int64', expected = 'BIGINT' 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s @pytest.mark.parametrize( 2790s "integer, expected", 2790s [ 2790s ("int8", "SMALLINT"), 2790s ("Int8", "SMALLINT"), 2790s ("uint8", "SMALLINT"), 2790s ("UInt8", "SMALLINT"), 2790s ("int16", "SMALLINT"), 2790s ("Int16", "SMALLINT"), 2790s ("uint16", "INTEGER"), 2790s ("UInt16", "INTEGER"), 2790s ("int32", "INTEGER"), 2790s ("Int32", "INTEGER"), 2790s ("uint32", "BIGINT"), 2790s ("UInt32", "BIGINT"), 2790s ("int64", "BIGINT"), 2790s ("Int64", "BIGINT"), 2790s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2790s ], 2790s ) 2790s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2790s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ______ test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_engine] ______ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s integer = 'Int64', expected = 'BIGINT' 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s @pytest.mark.parametrize( 2790s "integer, expected", 2790s [ 2790s ("int8", "SMALLINT"), 2790s ("Int8", "SMALLINT"), 2790s ("uint8", "SMALLINT"), 2790s ("UInt8", "SMALLINT"), 2790s ("int16", "SMALLINT"), 2790s ("Int16", "SMALLINT"), 2790s ("uint16", "INTEGER"), 2790s ("UInt16", "INTEGER"), 2790s ("int32", "INTEGER"), 2790s ("Int32", "INTEGER"), 2790s ("uint32", "BIGINT"), 2790s ("UInt32", "BIGINT"), 2790s ("int64", "BIGINT"), 2790s ("Int64", "BIGINT"), 2790s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2790s ], 2790s ) 2790s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2790s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2790s conn = request.getfixturevalue(conn) 2790s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2790s > with sql.SQLDatabase(conn) as db: 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _______ test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_conn] _______ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s integer = 'Int64', expected = 'BIGINT' 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s @pytest.mark.parametrize( 2790s "integer, expected", 2790s [ 2790s ("int8", "SMALLINT"), 2790s ("Int8", "SMALLINT"), 2790s ("uint8", "SMALLINT"), 2790s ("UInt8", "SMALLINT"), 2790s ("int16", "SMALLINT"), 2790s ("Int16", "SMALLINT"), 2790s ("uint16", "INTEGER"), 2790s ("UInt16", "INTEGER"), 2790s ("int32", "INTEGER"), 2790s ("Int32", "INTEGER"), 2790s ("uint32", "BIGINT"), 2790s ("UInt32", "BIGINT"), 2790s ("int64", "BIGINT"), 2790s ("Int64", "BIGINT"), 2790s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2790s ], 2790s ) 2790s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2790s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ___ test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_engine] ___ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s integer = 'Int64', expected = 'BIGINT' 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s @pytest.mark.parametrize( 2790s "integer, expected", 2790s [ 2790s ("int8", "SMALLINT"), 2790s ("Int8", "SMALLINT"), 2790s ("uint8", "SMALLINT"), 2790s ("UInt8", "SMALLINT"), 2790s ("int16", "SMALLINT"), 2790s ("Int16", "SMALLINT"), 2790s ("uint16", "INTEGER"), 2790s ("UInt16", "INTEGER"), 2790s ("int32", "INTEGER"), 2790s ("Int32", "INTEGER"), 2790s ("uint32", "BIGINT"), 2790s ("UInt32", "BIGINT"), 2790s ("int64", "BIGINT"), 2790s ("Int64", "BIGINT"), 2790s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2790s ], 2790s ) 2790s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2790s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2790s conn = request.getfixturevalue(conn) 2790s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2790s > with sql.SQLDatabase(conn) as db: 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ____ test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_conn] ____ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s integer = 'Int64', expected = 'BIGINT' 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s @pytest.mark.parametrize( 2790s "integer, expected", 2790s [ 2790s ("int8", "SMALLINT"), 2790s ("Int8", "SMALLINT"), 2790s ("uint8", "SMALLINT"), 2790s ("UInt8", "SMALLINT"), 2790s ("int16", "SMALLINT"), 2790s ("Int16", "SMALLINT"), 2790s ("uint16", "INTEGER"), 2790s ("UInt16", "INTEGER"), 2790s ("int32", "INTEGER"), 2790s ("Int32", "INTEGER"), 2790s ("uint32", "BIGINT"), 2790s ("UInt32", "BIGINT"), 2790s ("int64", "BIGINT"), 2790s ("Int64", "BIGINT"), 2790s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2790s ], 2790s ) 2790s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2790s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ______ test_sqlalchemy_integer_mapping[int-INTEGER-mysql_pymysql_engine] _______ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s integer = , expected = 'INTEGER' 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s @pytest.mark.parametrize( 2790s "integer, expected", 2790s [ 2790s ("int8", "SMALLINT"), 2790s ("Int8", "SMALLINT"), 2790s ("uint8", "SMALLINT"), 2790s ("UInt8", "SMALLINT"), 2790s ("int16", "SMALLINT"), 2790s ("Int16", "SMALLINT"), 2790s ("uint16", "INTEGER"), 2790s ("UInt16", "INTEGER"), 2790s ("int32", "INTEGER"), 2790s ("Int32", "INTEGER"), 2790s ("uint32", "BIGINT"), 2790s ("UInt32", "BIGINT"), 2790s ("int64", "BIGINT"), 2790s ("Int64", "BIGINT"), 2790s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2790s ], 2790s ) 2790s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2790s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2790s conn = request.getfixturevalue(conn) 2790s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2790s > with sql.SQLDatabase(conn) as db: 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _______ test_sqlalchemy_integer_mapping[int-INTEGER-mysql_pymysql_conn] ________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s integer = , expected = 'INTEGER' 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s @pytest.mark.parametrize( 2790s "integer, expected", 2790s [ 2790s ("int8", "SMALLINT"), 2790s ("Int8", "SMALLINT"), 2790s ("uint8", "SMALLINT"), 2790s ("UInt8", "SMALLINT"), 2790s ("int16", "SMALLINT"), 2790s ("Int16", "SMALLINT"), 2790s ("uint16", "INTEGER"), 2790s ("UInt16", "INTEGER"), 2790s ("int32", "INTEGER"), 2790s ("Int32", "INTEGER"), 2790s ("uint32", "BIGINT"), 2790s ("UInt32", "BIGINT"), 2790s ("int64", "BIGINT"), 2790s ("Int64", "BIGINT"), 2790s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2790s ], 2790s ) 2790s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2790s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ___ test_sqlalchemy_integer_mapping[int-INTEGER-postgresql_psycopg2_engine] ____ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s integer = , expected = 'INTEGER' 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s @pytest.mark.parametrize( 2790s "integer, expected", 2790s [ 2790s ("int8", "SMALLINT"), 2790s ("Int8", "SMALLINT"), 2790s ("uint8", "SMALLINT"), 2790s ("UInt8", "SMALLINT"), 2790s ("int16", "SMALLINT"), 2790s ("Int16", "SMALLINT"), 2790s ("uint16", "INTEGER"), 2790s ("UInt16", "INTEGER"), 2790s ("int32", "INTEGER"), 2790s ("Int32", "INTEGER"), 2790s ("uint32", "BIGINT"), 2790s ("UInt32", "BIGINT"), 2790s ("int64", "BIGINT"), 2790s ("Int64", "BIGINT"), 2790s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2790s ], 2790s ) 2790s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2790s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2790s conn = request.getfixturevalue(conn) 2790s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2790s > with sql.SQLDatabase(conn) as db: 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ____ test_sqlalchemy_integer_mapping[int-INTEGER-postgresql_psycopg2_conn] _____ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s integer = , expected = 'INTEGER' 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s @pytest.mark.parametrize( 2790s "integer, expected", 2790s [ 2790s ("int8", "SMALLINT"), 2790s ("Int8", "SMALLINT"), 2790s ("uint8", "SMALLINT"), 2790s ("UInt8", "SMALLINT"), 2790s ("int16", "SMALLINT"), 2790s ("Int16", "SMALLINT"), 2790s ("uint16", "INTEGER"), 2790s ("UInt16", "INTEGER"), 2790s ("int32", "INTEGER"), 2790s ("Int32", "INTEGER"), 2790s ("uint32", "BIGINT"), 2790s ("UInt32", "BIGINT"), 2790s ("int64", "BIGINT"), 2790s ("Int64", "BIGINT"), 2790s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2790s ], 2790s ) 2790s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2790s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ____ test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_engine] _____ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s integer = 'uint64' 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 2790s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 2790s conn = request.getfixturevalue(conn) 2790s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2790s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2790s > with sql.SQLDatabase(conn) as db: 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2509: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _____ test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_conn] ______ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s integer = 'uint64' 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 2790s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2506: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _ test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_engine] __ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s integer = 'uint64' 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 2790s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 2790s conn = request.getfixturevalue(conn) 2790s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2790s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2790s > with sql.SQLDatabase(conn) as db: 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2509: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s __ test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_conn] ___ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s integer = 'uint64' 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 2790s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2506: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ____ test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_engine] _____ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s integer = 'UInt64' 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 2790s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 2790s conn = request.getfixturevalue(conn) 2790s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2790s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2790s > with sql.SQLDatabase(conn) as db: 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2509: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _____ test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_conn] ______ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s integer = 'UInt64' 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 2790s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2506: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _ test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_engine] __ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s integer = 'UInt64' 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 2790s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 2790s conn = request.getfixturevalue(conn) 2790s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2790s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2790s > with sql.SQLDatabase(conn) as db: 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2509: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s __ test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_conn] ___ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s integer = 'UInt64' 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 2790s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2506: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _________________ test_database_uri_string[mysql_pymysql_conn] _________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s test_frame1 = index A B C D 2790s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2790s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s def test_database_uri_string(conn, request, test_frame1): 2790s td.versioned_importorskip("sqlalchemy") 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2519: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ______________ test_database_uri_string[postgresql_psycopg2_conn] ______________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s test_frame1 = index A B C D 2790s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2790s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s def test_database_uri_string(conn, request, test_frame1): 2790s td.versioned_importorskip("sqlalchemy") 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2519: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _________ test_pg8000_sqlalchemy_passthrough_error[mysql_pymysql_conn] _________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s 2790s @td.skip_if_installed("pg8000") 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s def test_pg8000_sqlalchemy_passthrough_error(conn, request): 2790s td.versioned_importorskip("sqlalchemy") 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2541: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ______ test_pg8000_sqlalchemy_passthrough_error[postgresql_psycopg2_conn] ______ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s 2790s @td.skip_if_installed("pg8000") 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s def test_pg8000_sqlalchemy_passthrough_error(conn, request): 2790s td.versioned_importorskip("sqlalchemy") 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2541: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ______________ test_query_by_text_obj[mysql_pymysql_engine_iris] _______________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_engine_iris' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2790s def test_query_by_text_obj(conn, request): 2790s # WIP : GH10846 2790s conn_name = conn 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2553: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2790s create_and_load_iris(mysql_pymysql_engine, iris_path) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2790s with conn.begin() as con: 2790s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2790s return next(self.gen) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2790s with self.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _______________ test_query_by_text_obj[mysql_pymysql_conn_iris] ________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn_iris' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2790s def test_query_by_text_obj(conn, request): 2790s # WIP : GH10846 2790s conn_name = conn 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2553: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2790s fixturedef = request._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2790s create_and_load_iris(mysql_pymysql_engine, iris_path) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2790s with conn.begin() as con: 2790s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2790s return next(self.gen) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2790s with self.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ___________ test_query_by_text_obj[postgresql_psycopg2_engine_iris] ____________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_engine_iris' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2790s def test_query_by_text_obj(conn, request): 2790s # WIP : GH10846 2790s conn_name = conn 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2553: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2790s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2790s with conn.begin() as con: 2790s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2790s return next(self.gen) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2790s with self.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ____________ test_query_by_text_obj[postgresql_psycopg2_conn_iris] _____________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn_iris' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2790s def test_query_by_text_obj(conn, request): 2790s # WIP : GH10846 2790s conn_name = conn 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2553: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2790s fixturedef = request._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2790s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2790s with conn.begin() as con: 2790s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2790s return next(self.gen) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2790s with self.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _____________ test_query_by_select_obj[mysql_pymysql_engine_iris] ______________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_engine_iris' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2790s def test_query_by_select_obj(conn, request): 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2567: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2790s create_and_load_iris(mysql_pymysql_engine, iris_path) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2790s with conn.begin() as con: 2790s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2790s return next(self.gen) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2790s with self.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ______________ test_query_by_select_obj[mysql_pymysql_conn_iris] _______________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn_iris' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2790s def test_query_by_select_obj(conn, request): 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2567: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2790s fixturedef = request._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2790s create_and_load_iris(mysql_pymysql_engine, iris_path) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2790s with conn.begin() as con: 2790s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2790s return next(self.gen) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2790s with self.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s __________ test_query_by_select_obj[postgresql_psycopg2_engine_iris] ___________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_engine_iris' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2790s def test_query_by_select_obj(conn, request): 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2567: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2790s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2790s with conn.begin() as con: 2790s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2790s return next(self.gen) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2790s with self.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ___________ test_query_by_select_obj[postgresql_psycopg2_conn_iris] ____________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn_iris' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2790s def test_query_by_select_obj(conn, request): 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2567: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2790s fixturedef = request._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2790s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2790s with conn.begin() as con: 2790s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2790s return next(self.gen) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2790s with self.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ______________ test_column_with_percentage[mysql_pymysql_engine] _______________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s def test_column_with_percentage(conn, request): 2790s # GH 37157 2790s conn_name = conn 2790s if conn_name == "sqlite_buildin": 2790s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 2790s 2790s conn = request.getfixturevalue(conn) 2790s df = DataFrame({"A": [0, 1, 2], "%_variation": [3, 4, 5]}) 2790s > df.to_sql(name="test_column_percentage", con=conn, index=False) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2590: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _______________ test_column_with_percentage[mysql_pymysql_conn] ________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s def test_column_with_percentage(conn, request): 2790s # GH 37157 2790s conn_name = conn 2790s if conn_name == "sqlite_buildin": 2790s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 2790s 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2588: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ___________ test_column_with_percentage[postgresql_psycopg2_engine] ____________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s def test_column_with_percentage(conn, request): 2790s # GH 37157 2790s conn_name = conn 2790s if conn_name == "sqlite_buildin": 2790s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 2790s 2790s conn = request.getfixturevalue(conn) 2790s df = DataFrame({"A": [0, 1, 2], "%_variation": [3, 4, 5]}) 2790s > df.to_sql(name="test_column_percentage", con=conn, index=False) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2590: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ____________ test_column_with_percentage[postgresql_psycopg2_conn] _____________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s def test_column_with_percentage(conn, request): 2790s # GH 37157 2790s conn_name = conn 2790s if conn_name == "sqlite_buildin": 2790s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 2790s 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2588: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ___________________ test_create_table[mysql_pymysql_engine] ____________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_create_table(conn, request): 2790s if conn == "sqlite_str": 2790s pytest.skip("sqlite_str has no inspection system") 2790s 2790s conn = request.getfixturevalue(conn) 2790s 2790s from sqlalchemy import inspect 2790s 2790s temp_frame = DataFrame({"one": [1.0, 2.0, 3.0, 4.0], "two": [4.0, 3.0, 2.0, 1.0]}) 2790s > with sql.SQLDatabase(conn, need_transaction=True) as pandasSQL: 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2681: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ____________________ test_create_table[mysql_pymysql_conn] _____________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_create_table(conn, request): 2790s if conn == "sqlite_str": 2790s pytest.skip("sqlite_str has no inspection system") 2790s 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2676: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ________________ test_create_table[postgresql_psycopg2_engine] _________________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_create_table(conn, request): 2790s if conn == "sqlite_str": 2790s pytest.skip("sqlite_str has no inspection system") 2790s 2790s conn = request.getfixturevalue(conn) 2790s 2790s from sqlalchemy import inspect 2790s 2790s temp_frame = DataFrame({"one": [1.0, 2.0, 3.0, 4.0], "two": [4.0, 3.0, 2.0, 1.0]}) 2790s > with sql.SQLDatabase(conn, need_transaction=True) as pandasSQL: 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2681: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _________________ test_create_table[postgresql_psycopg2_conn] __________________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_create_table(conn, request): 2790s if conn == "sqlite_str": 2790s pytest.skip("sqlite_str has no inspection system") 2790s 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2676: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ____________________ test_drop_table[mysql_pymysql_engine] _____________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_drop_table(conn, request): 2790s if conn == "sqlite_str": 2790s pytest.skip("sqlite_str has no inspection system") 2790s 2790s conn = request.getfixturevalue(conn) 2790s 2790s from sqlalchemy import inspect 2790s 2790s temp_frame = DataFrame({"one": [1.0, 2.0, 3.0, 4.0], "two": [4.0, 3.0, 2.0, 1.0]}) 2790s > with sql.SQLDatabase(conn) as pandasSQL: 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2702: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _____________________ test_drop_table[mysql_pymysql_conn] ______________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_drop_table(conn, request): 2790s if conn == "sqlite_str": 2790s pytest.skip("sqlite_str has no inspection system") 2790s 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2697: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _________________ test_drop_table[postgresql_psycopg2_engine] __________________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_drop_table(conn, request): 2790s if conn == "sqlite_str": 2790s pytest.skip("sqlite_str has no inspection system") 2790s 2790s conn = request.getfixturevalue(conn) 2790s 2790s from sqlalchemy import inspect 2790s 2790s temp_frame = DataFrame({"one": [1.0, 2.0, 3.0, 4.0], "two": [4.0, 3.0, 2.0, 1.0]}) 2790s > with sql.SQLDatabase(conn) as pandasSQL: 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2702: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s __________________ test_drop_table[postgresql_psycopg2_conn] ___________________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_drop_table(conn, request): 2790s if conn == "sqlite_str": 2790s pytest.skip("sqlite_str has no inspection system") 2790s 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2697: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _____________________ test_roundtrip[mysql_pymysql_engine] _____________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s test_frame1 = index A B C D 2790s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2790s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s def test_roundtrip(conn, request, test_frame1): 2790s if conn == "sqlite_str": 2790s pytest.skip("sqlite_str has no inspection system") 2790s 2790s conn_name = conn 2790s conn = request.getfixturevalue(conn) 2790s > pandasSQL = pandasSQL_builder(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2725: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ______________________ test_roundtrip[mysql_pymysql_conn] ______________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s test_frame1 = index A B C D 2790s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2790s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s def test_roundtrip(conn, request, test_frame1): 2790s if conn == "sqlite_str": 2790s pytest.skip("sqlite_str has no inspection system") 2790s 2790s conn_name = conn 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2724: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s __________________ test_roundtrip[postgresql_psycopg2_engine] __________________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s test_frame1 = index A B C D 2790s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2790s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s def test_roundtrip(conn, request, test_frame1): 2790s if conn == "sqlite_str": 2790s pytest.skip("sqlite_str has no inspection system") 2790s 2790s conn_name = conn 2790s conn = request.getfixturevalue(conn) 2790s > pandasSQL = pandasSQL_builder(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2725: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ___________________ test_roundtrip[postgresql_psycopg2_conn] ___________________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s test_frame1 = index A B C D 2790s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2790s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s def test_roundtrip(conn, request, test_frame1): 2790s if conn == "sqlite_str": 2790s pytest.skip("sqlite_str has no inspection system") 2790s 2790s conn_name = conn 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2724: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _________________ test_execute_sql[mysql_pymysql_engine_iris] __________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_engine_iris' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", all_connectable_iris) 2790s def test_execute_sql(conn, request): 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2742: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2790s create_and_load_iris(mysql_pymysql_engine, iris_path) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2790s with conn.begin() as con: 2790s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2790s return next(self.gen) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2790s with self.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s __________________ test_execute_sql[mysql_pymysql_conn_iris] ___________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn_iris' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", all_connectable_iris) 2790s def test_execute_sql(conn, request): 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2742: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2790s fixturedef = request._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2790s create_and_load_iris(mysql_pymysql_engine, iris_path) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2790s with conn.begin() as con: 2790s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2790s return next(self.gen) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2790s with self.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ______________ test_execute_sql[postgresql_psycopg2_engine_iris] _______________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_engine_iris' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", all_connectable_iris) 2790s def test_execute_sql(conn, request): 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2742: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2790s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2790s with conn.begin() as con: 2790s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2790s return next(self.gen) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2790s with self.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _______________ test_execute_sql[postgresql_psycopg2_conn_iris] ________________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn_iris' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", all_connectable_iris) 2790s def test_execute_sql(conn, request): 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2742: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2790s fixturedef = request._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2790s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2790s with conn.begin() as con: 2790s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2790s return next(self.gen) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2790s with self.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ____________ test_sqlalchemy_read_table[mysql_pymysql_engine_iris] _____________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_engine_iris' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2790s def test_sqlalchemy_read_table(conn, request): 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2753: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2790s create_and_load_iris(mysql_pymysql_engine, iris_path) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2790s with conn.begin() as con: 2790s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2790s return next(self.gen) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2790s with self.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _____________ test_sqlalchemy_read_table[mysql_pymysql_conn_iris] ______________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn_iris' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2790s def test_sqlalchemy_read_table(conn, request): 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2753: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2790s fixturedef = request._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2790s create_and_load_iris(mysql_pymysql_engine, iris_path) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2790s with conn.begin() as con: 2790s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2790s return next(self.gen) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2790s with self.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _________ test_sqlalchemy_read_table[postgresql_psycopg2_engine_iris] __________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_engine_iris' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2790s def test_sqlalchemy_read_table(conn, request): 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2753: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2790s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2790s with conn.begin() as con: 2790s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2790s return next(self.gen) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2790s with self.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s __________ test_sqlalchemy_read_table[postgresql_psycopg2_conn_iris] ___________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn_iris' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2790s def test_sqlalchemy_read_table(conn, request): 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2753: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2790s fixturedef = request._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2790s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2790s with conn.begin() as con: 2790s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2790s return next(self.gen) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2790s with self.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ________ test_sqlalchemy_read_table_columns[mysql_pymysql_engine_iris] _________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_engine_iris' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2790s def test_sqlalchemy_read_table_columns(conn, request): 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2760: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2790s create_and_load_iris(mysql_pymysql_engine, iris_path) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2790s with conn.begin() as con: 2790s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2790s return next(self.gen) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2790s with self.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _________ test_sqlalchemy_read_table_columns[mysql_pymysql_conn_iris] __________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn_iris' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2790s def test_sqlalchemy_read_table_columns(conn, request): 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2760: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2790s fixturedef = request._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2790s create_and_load_iris(mysql_pymysql_engine, iris_path) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2790s with conn.begin() as con: 2790s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2790s return next(self.gen) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2790s with self.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _____ test_sqlalchemy_read_table_columns[postgresql_psycopg2_engine_iris] ______ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_engine_iris' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2790s def test_sqlalchemy_read_table_columns(conn, request): 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2760: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2790s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2790s with conn.begin() as con: 2790s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2790s return next(self.gen) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2790s with self.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ______ test_sqlalchemy_read_table_columns[postgresql_psycopg2_conn_iris] _______ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn_iris' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2790s def test_sqlalchemy_read_table_columns(conn, request): 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2760: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2790s fixturedef = request._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2790s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2790s with conn.begin() as con: 2790s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2790s return next(self.gen) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2790s with self.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ___________ test_read_table_absent_raises[mysql_pymysql_engine_iris] ___________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_engine_iris' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2790s def test_read_table_absent_raises(conn, request): 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2769: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2790s create_and_load_iris(mysql_pymysql_engine, iris_path) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2790s with conn.begin() as con: 2790s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2790s return next(self.gen) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2790s with self.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ____________ test_read_table_absent_raises[mysql_pymysql_conn_iris] ____________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn_iris' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2790s def test_read_table_absent_raises(conn, request): 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2769: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2790s fixturedef = request._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2790s create_and_load_iris(mysql_pymysql_engine, iris_path) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2790s with conn.begin() as con: 2790s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2790s return next(self.gen) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2790s with self.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ________ test_read_table_absent_raises[postgresql_psycopg2_engine_iris] ________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_engine_iris' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2790s def test_read_table_absent_raises(conn, request): 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2769: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2790s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2790s with conn.begin() as con: 2790s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2790s return next(self.gen) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2790s with self.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _________ test_read_table_absent_raises[postgresql_psycopg2_conn_iris] _________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn_iris' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2790s def test_read_table_absent_raises(conn, request): 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2769: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2790s fixturedef = request._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2790s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2790s with conn.begin() as con: 2790s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2790s return next(self.gen) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2790s with self.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s __ test_sqlalchemy_default_type_conversion[postgresql_psycopg2_engine_types] ___ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_engine_types' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 2790s def test_sqlalchemy_default_type_conversion(conn, request): 2790s conn_name = conn 2790s if conn_name == "sqlite_str": 2790s pytest.skip("types tables not created in sqlite_str fixture") 2790s elif "mysql" in conn_name or "sqlite" in conn_name: 2790s request.applymarker( 2790s pytest.mark.xfail(reason="boolean dtype not inferred properly") 2790s ) 2790s 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2785: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2790s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2790s with conn.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ___ test_sqlalchemy_default_type_conversion[postgresql_psycopg2_conn_types] ____ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn_types' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 2790s def test_sqlalchemy_default_type_conversion(conn, request): 2790s conn_name = conn 2790s if conn_name == "sqlite_str": 2790s pytest.skip("types tables not created in sqlite_str fixture") 2790s elif "mysql" in conn_name or "sqlite" in conn_name: 2790s request.applymarker( 2790s pytest.mark.xfail(reason="boolean dtype not inferred properly") 2790s ) 2790s 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2785: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2790s fixturedef = request._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2790s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2790s with conn.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ______________________ test_bigint[mysql_pymysql_engine] _______________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_bigint(conn, request): 2790s # int64 should be converted to BigInteger, GH7433 2790s conn = request.getfixturevalue(conn) 2790s df = DataFrame(data={"i64": [2**62]}) 2790s > assert df.to_sql(name="test_bigint", con=conn, index=False) == 1 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2803: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _______________________ test_bigint[mysql_pymysql_conn] ________________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_bigint(conn, request): 2790s # int64 should be converted to BigInteger, GH7433 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2801: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ___________________ test_bigint[postgresql_psycopg2_engine] ____________________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_bigint(conn, request): 2790s # int64 should be converted to BigInteger, GH7433 2790s conn = request.getfixturevalue(conn) 2790s df = DataFrame(data={"i64": [2**62]}) 2790s > assert df.to_sql(name="test_bigint", con=conn, index=False) == 1 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2803: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ____________________ test_bigint[postgresql_psycopg2_conn] _____________________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_bigint(conn, request): 2790s # int64 should be converted to BigInteger, GH7433 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2801: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ______________ test_default_date_load[mysql_pymysql_engine_types] ______________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_engine_types' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 2790s def test_default_date_load(conn, request): 2790s conn_name = conn 2790s if conn_name == "sqlite_str": 2790s pytest.skip("types tables not created in sqlite_str fixture") 2790s elif "sqlite" in conn_name: 2790s request.applymarker( 2790s pytest.mark.xfail(reason="sqlite does not read date properly") 2790s ) 2790s 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2819: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2790s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2790s with conn.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _______________ test_default_date_load[mysql_pymysql_conn_types] _______________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn_types' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 2790s def test_default_date_load(conn, request): 2790s conn_name = conn 2790s if conn_name == "sqlite_str": 2790s pytest.skip("types tables not created in sqlite_str fixture") 2790s elif "sqlite" in conn_name: 2790s request.applymarker( 2790s pytest.mark.xfail(reason="sqlite does not read date properly") 2790s ) 2790s 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2819: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2790s fixturedef = request._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2790s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2790s with conn.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ___________ test_default_date_load[postgresql_psycopg2_engine_types] ___________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_engine_types' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 2790s def test_default_date_load(conn, request): 2790s conn_name = conn 2790s if conn_name == "sqlite_str": 2790s pytest.skip("types tables not created in sqlite_str fixture") 2790s elif "sqlite" in conn_name: 2790s request.applymarker( 2790s pytest.mark.xfail(reason="sqlite does not read date properly") 2790s ) 2790s 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2819: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2790s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2790s with conn.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ____________ test_default_date_load[postgresql_psycopg2_conn_types] ____________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn_types' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 2790s def test_default_date_load(conn, request): 2790s conn_name = conn 2790s if conn_name == "sqlite_str": 2790s pytest.skip("types tables not created in sqlite_str fixture") 2790s elif "sqlite" in conn_name: 2790s request.applymarker( 2790s pytest.mark.xfail(reason="sqlite does not read date properly") 2790s ) 2790s 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2819: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2790s fixturedef = request._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2790s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2790s with conn.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ______ test_datetime_with_timezone_query[None-postgresql_psycopg2_engine] ______ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s parse_dates = None 2790s 2790s @pytest.mark.parametrize("conn", postgresql_connectable) 2790s @pytest.mark.parametrize("parse_dates", [None, ["DateColWithTz"]]) 2790s def test_datetime_with_timezone_query(conn, request, parse_dates): 2790s # edge case that converts postgresql datetime with time zone types 2790s # to datetime64[ns,psycopg2.tz.FixedOffsetTimezone..], which is ok 2790s # but should be more natural, so coerce to datetime64[ns] for now 2790s conn = request.getfixturevalue(conn) 2790s > expected = create_and_load_postgres_datetz(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2832: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:351: in create_and_load_postgres_datetz 2790s with conn.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _______ test_datetime_with_timezone_query[None-postgresql_psycopg2_conn] _______ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s parse_dates = None 2790s 2790s @pytest.mark.parametrize("conn", postgresql_connectable) 2790s @pytest.mark.parametrize("parse_dates", [None, ["DateColWithTz"]]) 2790s def test_datetime_with_timezone_query(conn, request, parse_dates): 2790s # edge case that converts postgresql datetime with time zone types 2790s # to datetime64[ns,psycopg2.tz.FixedOffsetTimezone..], which is ok 2790s # but should be more natural, so coerce to datetime64[ns] for now 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2831: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s __ test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_engine] __ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s parse_dates = ['DateColWithTz'] 2790s 2790s @pytest.mark.parametrize("conn", postgresql_connectable) 2790s @pytest.mark.parametrize("parse_dates", [None, ["DateColWithTz"]]) 2790s def test_datetime_with_timezone_query(conn, request, parse_dates): 2790s # edge case that converts postgresql datetime with time zone types 2790s # to datetime64[ns,psycopg2.tz.FixedOffsetTimezone..], which is ok 2790s # but should be more natural, so coerce to datetime64[ns] for now 2790s conn = request.getfixturevalue(conn) 2790s > expected = create_and_load_postgres_datetz(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2832: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:351: in create_and_load_postgres_datetz 2790s with conn.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ___ test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_conn] ___ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s parse_dates = ['DateColWithTz'] 2790s 2790s @pytest.mark.parametrize("conn", postgresql_connectable) 2790s @pytest.mark.parametrize("parse_dates", [None, ["DateColWithTz"]]) 2790s def test_datetime_with_timezone_query(conn, request, parse_dates): 2790s # edge case that converts postgresql datetime with time zone types 2790s # to datetime64[ns,psycopg2.tz.FixedOffsetTimezone..], which is ok 2790s # but should be more natural, so coerce to datetime64[ns] for now 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2831: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ___ test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_engine] ____ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", postgresql_connectable) 2790s def test_datetime_with_timezone_query_chunksize(conn, request): 2790s conn = request.getfixturevalue(conn) 2790s > expected = create_and_load_postgres_datetz(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2843: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:351: in create_and_load_postgres_datetz 2790s with conn.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ____ test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_conn] _____ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", postgresql_connectable) 2790s def test_datetime_with_timezone_query_chunksize(conn, request): 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2842: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ________ test_datetime_with_timezone_table[postgresql_psycopg2_engine] _________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", postgresql_connectable) 2790s def test_datetime_with_timezone_table(conn, request): 2790s conn = request.getfixturevalue(conn) 2790s > expected = create_and_load_postgres_datetz(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2856: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:351: in create_and_load_postgres_datetz 2790s with conn.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _________ test_datetime_with_timezone_table[postgresql_psycopg2_conn] __________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", postgresql_connectable) 2790s def test_datetime_with_timezone_table(conn, request): 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2855: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _________ test_datetime_with_timezone_roundtrip[mysql_pymysql_engine] __________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_datetime_with_timezone_roundtrip(conn, request): 2790s conn_name = conn 2790s conn = request.getfixturevalue(conn) 2790s # GH 9086 2790s # Write datetimetz data to a db and read it back 2790s # For dbs that support timestamps with timezones, should get back UTC 2790s # otherwise naive data should be returned 2790s expected = DataFrame( 2790s {"A": date_range("2013-01-01 09:00:00", periods=3, tz="US/Pacific")} 2790s ) 2790s > assert expected.to_sql(name="test_datetime_tz", con=conn, index=False) == 3 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2872: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s __________ test_datetime_with_timezone_roundtrip[mysql_pymysql_conn] ___________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_datetime_with_timezone_roundtrip(conn, request): 2790s conn_name = conn 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2864: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ______ test_datetime_with_timezone_roundtrip[postgresql_psycopg2_engine] _______ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_datetime_with_timezone_roundtrip(conn, request): 2790s conn_name = conn 2790s conn = request.getfixturevalue(conn) 2790s # GH 9086 2790s # Write datetimetz data to a db and read it back 2790s # For dbs that support timestamps with timezones, should get back UTC 2790s # otherwise naive data should be returned 2790s expected = DataFrame( 2790s {"A": date_range("2013-01-01 09:00:00", periods=3, tz="US/Pacific")} 2790s ) 2790s > assert expected.to_sql(name="test_datetime_tz", con=conn, index=False) == 3 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2872: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _______ test_datetime_with_timezone_roundtrip[postgresql_psycopg2_conn] ________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_datetime_with_timezone_roundtrip(conn, request): 2790s conn_name = conn 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2864: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ______________ test_out_of_bounds_datetime[mysql_pymysql_engine] _______________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_out_of_bounds_datetime(conn, request): 2790s # GH 26761 2790s conn = request.getfixturevalue(conn) 2790s data = DataFrame({"date": datetime(9999, 1, 1)}, index=[0]) 2790s > assert data.to_sql(name="test_datetime_obb", con=conn, index=False) == 1 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2897: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _______________ test_out_of_bounds_datetime[mysql_pymysql_conn] ________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_out_of_bounds_datetime(conn, request): 2790s # GH 26761 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2895: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ___________ test_out_of_bounds_datetime[postgresql_psycopg2_engine] ____________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_out_of_bounds_datetime(conn, request): 2790s # GH 26761 2790s conn = request.getfixturevalue(conn) 2790s data = DataFrame({"date": datetime(9999, 1, 1)}, index=[0]) 2790s > assert data.to_sql(name="test_datetime_obb", con=conn, index=False) == 1 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2897: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ____________ test_out_of_bounds_datetime[postgresql_psycopg2_conn] _____________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_out_of_bounds_datetime(conn, request): 2790s # GH 26761 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2895: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ___________ test_naive_datetimeindex_roundtrip[mysql_pymysql_engine] ___________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_naive_datetimeindex_roundtrip(conn, request): 2790s # GH 23510 2790s # Ensure that a naive DatetimeIndex isn't converted to UTC 2790s conn = request.getfixturevalue(conn) 2790s dates = date_range("2018-01-01", periods=5, freq="6h")._with_freq(None) 2790s expected = DataFrame({"nums": range(5)}, index=dates) 2790s > assert expected.to_sql(name="foo_table", con=conn, index_label="info_date") == 5 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2910: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ____________ test_naive_datetimeindex_roundtrip[mysql_pymysql_conn] ____________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_naive_datetimeindex_roundtrip(conn, request): 2790s # GH 23510 2790s # Ensure that a naive DatetimeIndex isn't converted to UTC 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2907: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ________ test_naive_datetimeindex_roundtrip[postgresql_psycopg2_engine] ________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_naive_datetimeindex_roundtrip(conn, request): 2790s # GH 23510 2790s # Ensure that a naive DatetimeIndex isn't converted to UTC 2790s conn = request.getfixturevalue(conn) 2790s dates = date_range("2018-01-01", periods=5, freq="6h")._with_freq(None) 2790s expected = DataFrame({"nums": range(5)}, index=dates) 2790s > assert expected.to_sql(name="foo_table", con=conn, index_label="info_date") == 5 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2910: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _________ test_naive_datetimeindex_roundtrip[postgresql_psycopg2_conn] _________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_naive_datetimeindex_roundtrip(conn, request): 2790s # GH 23510 2790s # Ensure that a naive DatetimeIndex isn't converted to UTC 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2907: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ________________ test_date_parsing[mysql_pymysql_engine_types] _________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_engine_types' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 2790s def test_date_parsing(conn, request): 2790s # No Parsing 2790s conn_name = conn 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2920: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2790s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2790s with conn.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _________________ test_date_parsing[mysql_pymysql_conn_types] __________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn_types' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 2790s def test_date_parsing(conn, request): 2790s # No Parsing 2790s conn_name = conn 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2920: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2790s fixturedef = request._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2790s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2790s with conn.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _____________ test_date_parsing[postgresql_psycopg2_engine_types] ______________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_engine_types' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 2790s def test_date_parsing(conn, request): 2790s # No Parsing 2790s conn_name = conn 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2920: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2790s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2790s with conn.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ______________ test_date_parsing[postgresql_psycopg2_conn_types] _______________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn_types' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 2790s def test_date_parsing(conn, request): 2790s # No Parsing 2790s conn_name = conn 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2920: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2790s fixturedef = request._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2790s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2790s with conn.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _____________________ test_datetime[mysql_pymysql_engine] ______________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_datetime(conn, request): 2790s conn_name = conn 2790s conn = request.getfixturevalue(conn) 2790s df = DataFrame( 2790s {"A": date_range("2013-01-01 09:00:00", periods=3), "B": np.arange(3.0)} 2790s ) 2790s > assert df.to_sql(name="test_datetime", con=conn) == 3 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2955: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ______________________ test_datetime[mysql_pymysql_conn] _______________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_datetime(conn, request): 2790s conn_name = conn 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2951: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s __________________ test_datetime[postgresql_psycopg2_engine] ___________________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_datetime(conn, request): 2790s conn_name = conn 2790s conn = request.getfixturevalue(conn) 2790s df = DataFrame( 2790s {"A": date_range("2013-01-01 09:00:00", periods=3), "B": np.arange(3.0)} 2790s ) 2790s > assert df.to_sql(name="test_datetime", con=conn) == 3 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2955: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ___________________ test_datetime[postgresql_psycopg2_conn] ____________________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_datetime(conn, request): 2790s conn_name = conn 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2951: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ___________________ test_datetime_NaT[mysql_pymysql_engine] ____________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_datetime_NaT(conn, request): 2790s conn_name = conn 2790s conn = request.getfixturevalue(conn) 2790s df = DataFrame( 2790s {"A": date_range("2013-01-01 09:00:00", periods=3), "B": np.arange(3.0)} 2790s ) 2790s df.loc[1, "A"] = np.nan 2790s > assert df.to_sql(name="test_datetime", con=conn, index=False) == 3 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2981: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ____________________ test_datetime_NaT[mysql_pymysql_conn] _____________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_datetime_NaT(conn, request): 2790s conn_name = conn 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2976: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ________________ test_datetime_NaT[postgresql_psycopg2_engine] _________________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_datetime_NaT(conn, request): 2790s conn_name = conn 2790s conn = request.getfixturevalue(conn) 2790s df = DataFrame( 2790s {"A": date_range("2013-01-01 09:00:00", periods=3), "B": np.arange(3.0)} 2790s ) 2790s df.loc[1, "A"] = np.nan 2790s > assert df.to_sql(name="test_datetime", con=conn, index=False) == 3 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2981: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _________________ test_datetime_NaT[postgresql_psycopg2_conn] __________________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_datetime_NaT(conn, request): 2790s conn_name = conn 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2976: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ___________________ test_datetime_date[mysql_pymysql_engine] ___________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_datetime_date(conn, request): 2790s # test support for datetime.date 2790s conn = request.getfixturevalue(conn) 2790s df = DataFrame([date(2014, 1, 1), date(2014, 1, 2)], columns=["a"]) 2790s > assert df.to_sql(name="test_date", con=conn, index=False) == 2 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3002: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ____________________ test_datetime_date[mysql_pymysql_conn] ____________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_datetime_date(conn, request): 2790s # test support for datetime.date 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3000: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ________________ test_datetime_date[postgresql_psycopg2_engine] ________________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_datetime_date(conn, request): 2790s # test support for datetime.date 2790s conn = request.getfixturevalue(conn) 2790s df = DataFrame([date(2014, 1, 1), date(2014, 1, 2)], columns=["a"]) 2790s > assert df.to_sql(name="test_date", con=conn, index=False) == 2 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3002: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _________________ test_datetime_date[postgresql_psycopg2_conn] _________________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_datetime_date(conn, request): 2790s # test support for datetime.date 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3000: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ___________________ test_datetime_time[mysql_pymysql_engine] ___________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s sqlite_buildin = 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_datetime_time(conn, request, sqlite_buildin): 2790s # test support for datetime.time 2790s conn_name = conn 2790s conn = request.getfixturevalue(conn) 2790s df = DataFrame([time(9, 0, 0), time(9, 1, 30)], columns=["a"]) 2790s > assert df.to_sql(name="test_time", con=conn, index=False) == 2 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3016: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ____________________ test_datetime_time[mysql_pymysql_conn] ____________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s sqlite_buildin = 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_datetime_time(conn, request, sqlite_buildin): 2790s # test support for datetime.time 2790s conn_name = conn 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3014: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ________________ test_datetime_time[postgresql_psycopg2_engine] ________________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s sqlite_buildin = 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_datetime_time(conn, request, sqlite_buildin): 2790s # test support for datetime.time 2790s conn_name = conn 2790s conn = request.getfixturevalue(conn) 2790s df = DataFrame([time(9, 0, 0), time(9, 1, 30)], columns=["a"]) 2790s > assert df.to_sql(name="test_time", con=conn, index=False) == 2 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3016: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _________________ test_datetime_time[postgresql_psycopg2_conn] _________________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s sqlite_buildin = 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_datetime_time(conn, request, sqlite_buildin): 2790s # test support for datetime.time 2790s conn_name = conn 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3014: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ________________ test_mixed_dtype_insert[mysql_pymysql_engine] _________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_mixed_dtype_insert(conn, request): 2790s # see GH6509 2790s conn = request.getfixturevalue(conn) 2790s s1 = Series(2**25 + 1, dtype=np.int32) 2790s s2 = Series(0.0, dtype=np.float32) 2790s df = DataFrame({"s1": s1, "s2": s2}) 2790s 2790s # write and read again 2790s > assert df.to_sql(name="test_read_write", con=conn, index=False) == 1 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3046: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _________________ test_mixed_dtype_insert[mysql_pymysql_conn] __________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_mixed_dtype_insert(conn, request): 2790s # see GH6509 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3040: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _____________ test_mixed_dtype_insert[postgresql_psycopg2_engine] ______________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_mixed_dtype_insert(conn, request): 2790s # see GH6509 2790s conn = request.getfixturevalue(conn) 2790s s1 = Series(2**25 + 1, dtype=np.int32) 2790s s2 = Series(0.0, dtype=np.float32) 2790s df = DataFrame({"s1": s1, "s2": s2}) 2790s 2790s # write and read again 2790s > assert df.to_sql(name="test_read_write", con=conn, index=False) == 1 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3046: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ______________ test_mixed_dtype_insert[postgresql_psycopg2_conn] _______________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_mixed_dtype_insert(conn, request): 2790s # see GH6509 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3040: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ____________________ test_nan_numeric[mysql_pymysql_engine] ____________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_nan_numeric(conn, request): 2790s # NaNs in numeric float column 2790s conn = request.getfixturevalue(conn) 2790s df = DataFrame({"A": [0, 1, 2], "B": [0.2, np.nan, 5.6]}) 2790s > assert df.to_sql(name="test_nan", con=conn, index=False) == 3 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3057: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _____________________ test_nan_numeric[mysql_pymysql_conn] _____________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_nan_numeric(conn, request): 2790s # NaNs in numeric float column 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3055: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _________________ test_nan_numeric[postgresql_psycopg2_engine] _________________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_nan_numeric(conn, request): 2790s # NaNs in numeric float column 2790s conn = request.getfixturevalue(conn) 2790s df = DataFrame({"A": [0, 1, 2], "B": [0.2, np.nan, 5.6]}) 2790s > assert df.to_sql(name="test_nan", con=conn, index=False) == 3 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3057: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s __________________ test_nan_numeric[postgresql_psycopg2_conn] __________________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_nan_numeric(conn, request): 2790s # NaNs in numeric float column 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3055: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s __________________ test_nan_fullcolumn[mysql_pymysql_engine] ___________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_nan_fullcolumn(conn, request): 2790s # full NaN column (numeric float column) 2790s conn = request.getfixturevalue(conn) 2790s df = DataFrame({"A": [0, 1, 2], "B": [np.nan, np.nan, np.nan]}) 2790s > assert df.to_sql(name="test_nan", con=conn, index=False) == 3 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3073: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ___________________ test_nan_fullcolumn[mysql_pymysql_conn] ____________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_nan_fullcolumn(conn, request): 2790s # full NaN column (numeric float column) 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3071: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _______________ test_nan_fullcolumn[postgresql_psycopg2_engine] ________________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_nan_fullcolumn(conn, request): 2790s # full NaN column (numeric float column) 2790s conn = request.getfixturevalue(conn) 2790s df = DataFrame({"A": [0, 1, 2], "B": [np.nan, np.nan, np.nan]}) 2790s > assert df.to_sql(name="test_nan", con=conn, index=False) == 3 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3073: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ________________ test_nan_fullcolumn[postgresql_psycopg2_conn] _________________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_nan_fullcolumn(conn, request): 2790s # full NaN column (numeric float column) 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3071: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ____________________ test_nan_string[mysql_pymysql_engine] _____________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_nan_string(conn, request): 2790s # NaNs in string column 2790s conn = request.getfixturevalue(conn) 2790s df = DataFrame({"A": [0, 1, 2], "B": ["a", "b", np.nan]}) 2790s > assert df.to_sql(name="test_nan", con=conn, index=False) == 3 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3091: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _____________________ test_nan_string[mysql_pymysql_conn] ______________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_nan_string(conn, request): 2790s # NaNs in string column 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3089: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _________________ test_nan_string[postgresql_psycopg2_engine] __________________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_nan_string(conn, request): 2790s # NaNs in string column 2790s conn = request.getfixturevalue(conn) 2790s df = DataFrame({"A": [0, 1, 2], "B": ["a", "b", np.nan]}) 2790s > assert df.to_sql(name="test_nan", con=conn, index=False) == 3 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3091: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s __________________ test_nan_string[postgresql_psycopg2_conn] ___________________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_nan_string(conn, request): 2790s # NaNs in string column 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3089: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _________________ test_to_sql_save_index[mysql_pymysql_engine] _________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s def test_to_sql_save_index(conn, request): 2790s if "adbc" in conn: 2790s request.node.add_marker( 2790s pytest.mark.xfail( 2790s reason="ADBC implementation does not create index", strict=True 2790s ) 2790s ) 2790s conn_name = conn 2790s conn = request.getfixturevalue(conn) 2790s df = DataFrame.from_records( 2790s [(1, 2.1, "line1"), (2, 1.5, "line2")], columns=["A", "B", "C"], index=["A"] 2790s ) 2790s 2790s tbl_name = "test_to_sql_saves_index" 2790s > with pandasSQL_builder(conn) as pandasSQL: 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3120: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s __________________ test_to_sql_save_index[mysql_pymysql_conn] __________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s def test_to_sql_save_index(conn, request): 2790s if "adbc" in conn: 2790s request.node.add_marker( 2790s pytest.mark.xfail( 2790s reason="ADBC implementation does not create index", strict=True 2790s ) 2790s ) 2790s conn_name = conn 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3114: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ______________ test_to_sql_save_index[postgresql_psycopg2_engine] ______________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s def test_to_sql_save_index(conn, request): 2790s if "adbc" in conn: 2790s request.node.add_marker( 2790s pytest.mark.xfail( 2790s reason="ADBC implementation does not create index", strict=True 2790s ) 2790s ) 2790s conn_name = conn 2790s conn = request.getfixturevalue(conn) 2790s df = DataFrame.from_records( 2790s [(1, 2.1, "line1"), (2, 1.5, "line2")], columns=["A", "B", "C"], index=["A"] 2790s ) 2790s 2790s tbl_name = "test_to_sql_saves_index" 2790s > with pandasSQL_builder(conn) as pandasSQL: 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3120: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _______________ test_to_sql_save_index[postgresql_psycopg2_conn] _______________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s def test_to_sql_save_index(conn, request): 2790s if "adbc" in conn: 2790s request.node.add_marker( 2790s pytest.mark.xfail( 2790s reason="ADBC implementation does not create index", strict=True 2790s ) 2790s ) 2790s conn_name = conn 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3114: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ___________________ test_transactions[mysql_pymysql_engine] ____________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s def test_transactions(conn, request): 2790s conn_name = conn 2790s conn = request.getfixturevalue(conn) 2790s 2790s stmt = "CREATE TABLE test_trans (A INT, B TEXT)" 2790s if conn_name != "sqlite_buildin" and "adbc" not in conn_name: 2790s from sqlalchemy import text 2790s 2790s stmt = text(stmt) 2790s 2790s > with pandasSQL_builder(conn) as pandasSQL: 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3156: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ____________________ test_transactions[mysql_pymysql_conn] _____________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s def test_transactions(conn, request): 2790s conn_name = conn 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3148: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ________________ test_transactions[postgresql_psycopg2_engine] _________________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s def test_transactions(conn, request): 2790s conn_name = conn 2790s conn = request.getfixturevalue(conn) 2790s 2790s stmt = "CREATE TABLE test_trans (A INT, B TEXT)" 2790s if conn_name != "sqlite_buildin" and "adbc" not in conn_name: 2790s from sqlalchemy import text 2790s 2790s stmt = text(stmt) 2790s 2790s > with pandasSQL_builder(conn) as pandasSQL: 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3156: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _________________ test_transactions[postgresql_psycopg2_conn] __________________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s def test_transactions(conn, request): 2790s conn_name = conn 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3148: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _______________ test_transaction_rollback[mysql_pymysql_engine] ________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s def test_transaction_rollback(conn, request): 2790s conn_name = conn 2790s conn = request.getfixturevalue(conn) 2790s > with pandasSQL_builder(conn) as pandasSQL: 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3165: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ________________ test_transaction_rollback[mysql_pymysql_conn] _________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s def test_transaction_rollback(conn, request): 2790s conn_name = conn 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3164: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ____________ test_transaction_rollback[postgresql_psycopg2_engine] _____________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s def test_transaction_rollback(conn, request): 2790s conn_name = conn 2790s conn = request.getfixturevalue(conn) 2790s > with pandasSQL_builder(conn) as pandasSQL: 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3165: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _____________ test_transaction_rollback[postgresql_psycopg2_conn] ______________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s def test_transaction_rollback(conn, request): 2790s conn_name = conn 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3164: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ______________ test_get_schema_create_table[mysql_pymysql_engine] ______________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s test_frame3 = index A B 2790s 0 2000-01-03 00:00:00 2147483647 -1.987670 2790s 1 2000-01-04 00:00:00 -29 -0.041232 2790s 2 2000-01-05 00:00:00 20000 0.731168 2790s 3 2000-01-06 00:00:00 -290867 1.567621 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_get_schema_create_table(conn, request, test_frame3): 2790s # Use a dataframe without a bool column, since MySQL converts bool to 2790s # TINYINT (which read_sql_table returns as an int and causes a dtype 2790s # mismatch) 2790s if conn == "sqlite_str": 2790s request.applymarker( 2790s pytest.mark.xfail(reason="test does not support sqlite_str fixture") 2790s ) 2790s 2790s conn = request.getfixturevalue(conn) 2790s 2790s from sqlalchemy import text 2790s from sqlalchemy.engine import Engine 2790s 2790s tbl = "test_get_schema_create_table" 2790s > create_sql = sql.get_schema(test_frame3, tbl, con=conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3219: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 2790s with pandasSQL_builder(con=con) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _______________ test_get_schema_create_table[mysql_pymysql_conn] _______________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s test_frame3 = index A B 2790s 0 2000-01-03 00:00:00 2147483647 -1.987670 2790s 1 2000-01-04 00:00:00 -29 -0.041232 2790s 2 2000-01-05 00:00:00 20000 0.731168 2790s 3 2000-01-06 00:00:00 -290867 1.567621 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_get_schema_create_table(conn, request, test_frame3): 2790s # Use a dataframe without a bool column, since MySQL converts bool to 2790s # TINYINT (which read_sql_table returns as an int and causes a dtype 2790s # mismatch) 2790s if conn == "sqlite_str": 2790s request.applymarker( 2790s pytest.mark.xfail(reason="test does not support sqlite_str fixture") 2790s ) 2790s 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3213: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ___________ test_get_schema_create_table[postgresql_psycopg2_engine] ___________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s test_frame3 = index A B 2790s 0 2000-01-03 00:00:00 2147483647 -1.987670 2790s 1 2000-01-04 00:00:00 -29 -0.041232 2790s 2 2000-01-05 00:00:00 20000 0.731168 2790s 3 2000-01-06 00:00:00 -290867 1.567621 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_get_schema_create_table(conn, request, test_frame3): 2790s # Use a dataframe without a bool column, since MySQL converts bool to 2790s # TINYINT (which read_sql_table returns as an int and causes a dtype 2790s # mismatch) 2790s if conn == "sqlite_str": 2790s request.applymarker( 2790s pytest.mark.xfail(reason="test does not support sqlite_str fixture") 2790s ) 2790s 2790s conn = request.getfixturevalue(conn) 2790s 2790s from sqlalchemy import text 2790s from sqlalchemy.engine import Engine 2790s 2790s tbl = "test_get_schema_create_table" 2790s > create_sql = sql.get_schema(test_frame3, tbl, con=conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3219: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 2790s with pandasSQL_builder(con=con) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ____________ test_get_schema_create_table[postgresql_psycopg2_conn] ____________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s test_frame3 = index A B 2790s 0 2000-01-03 00:00:00 2147483647 -1.987670 2790s 1 2000-01-04 00:00:00 -29 -0.041232 2790s 2 2000-01-05 00:00:00 20000 0.731168 2790s 3 2000-01-06 00:00:00 -290867 1.567621 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_get_schema_create_table(conn, request, test_frame3): 2790s # Use a dataframe without a bool column, since MySQL converts bool to 2790s # TINYINT (which read_sql_table returns as an int and causes a dtype 2790s # mismatch) 2790s if conn == "sqlite_str": 2790s request.applymarker( 2790s pytest.mark.xfail(reason="test does not support sqlite_str fixture") 2790s ) 2790s 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3213: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _______________________ test_dtype[mysql_pymysql_engine] _______________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_dtype(conn, request): 2790s if conn == "sqlite_str": 2790s pytest.skip("sqlite_str has no inspection system") 2790s 2790s conn = request.getfixturevalue(conn) 2790s 2790s from sqlalchemy import ( 2790s TEXT, 2790s String, 2790s ) 2790s from sqlalchemy.schema import MetaData 2790s 2790s cols = ["A", "B"] 2790s data = [(0.8, True), (0.9, None)] 2790s df = DataFrame(data, columns=cols) 2790s > assert df.to_sql(name="dtype_test", con=conn) == 2 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3249: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ________________________ test_dtype[mysql_pymysql_conn] ________________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_dtype(conn, request): 2790s if conn == "sqlite_str": 2790s pytest.skip("sqlite_str has no inspection system") 2790s 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3238: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ____________________ test_dtype[postgresql_psycopg2_engine] ____________________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_dtype(conn, request): 2790s if conn == "sqlite_str": 2790s pytest.skip("sqlite_str has no inspection system") 2790s 2790s conn = request.getfixturevalue(conn) 2790s 2790s from sqlalchemy import ( 2790s TEXT, 2790s String, 2790s ) 2790s from sqlalchemy.schema import MetaData 2790s 2790s cols = ["A", "B"] 2790s data = [(0.8, True), (0.9, None)] 2790s df = DataFrame(data, columns=cols) 2790s > assert df.to_sql(name="dtype_test", con=conn) == 2 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3249: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _____________________ test_dtype[postgresql_psycopg2_conn] _____________________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_dtype(conn, request): 2790s if conn == "sqlite_str": 2790s pytest.skip("sqlite_str has no inspection system") 2790s 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3238: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ____________________ test_notna_dtype[mysql_pymysql_engine] ____________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_notna_dtype(conn, request): 2790s if conn == "sqlite_str": 2790s pytest.skip("sqlite_str has no inspection system") 2790s 2790s conn_name = conn 2790s conn = request.getfixturevalue(conn) 2790s 2790s from sqlalchemy import ( 2790s Boolean, 2790s DateTime, 2790s Float, 2790s Integer, 2790s ) 2790s from sqlalchemy.schema import MetaData 2790s 2790s cols = { 2790s "Bool": Series([True, None]), 2790s "Date": Series([datetime(2012, 5, 1), None]), 2790s "Int": Series([1, None], dtype="object"), 2790s "Float": Series([1.1, None]), 2790s } 2790s df = DataFrame(cols) 2790s 2790s tbl = "notna_dtype_test" 2790s > assert df.to_sql(name=tbl, con=conn) == 2 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3300: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _____________________ test_notna_dtype[mysql_pymysql_conn] _____________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_notna_dtype(conn, request): 2790s if conn == "sqlite_str": 2790s pytest.skip("sqlite_str has no inspection system") 2790s 2790s conn_name = conn 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3281: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _________________ test_notna_dtype[postgresql_psycopg2_engine] _________________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_notna_dtype(conn, request): 2790s if conn == "sqlite_str": 2790s pytest.skip("sqlite_str has no inspection system") 2790s 2790s conn_name = conn 2790s conn = request.getfixturevalue(conn) 2790s 2790s from sqlalchemy import ( 2790s Boolean, 2790s DateTime, 2790s Float, 2790s Integer, 2790s ) 2790s from sqlalchemy.schema import MetaData 2790s 2790s cols = { 2790s "Bool": Series([True, None]), 2790s "Date": Series([datetime(2012, 5, 1), None]), 2790s "Int": Series([1, None], dtype="object"), 2790s "Float": Series([1.1, None]), 2790s } 2790s df = DataFrame(cols) 2790s 2790s tbl = "notna_dtype_test" 2790s > assert df.to_sql(name=tbl, con=conn) == 2 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3300: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s __________________ test_notna_dtype[postgresql_psycopg2_conn] __________________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_notna_dtype(conn, request): 2790s if conn == "sqlite_str": 2790s pytest.skip("sqlite_str has no inspection system") 2790s 2790s conn_name = conn 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3281: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _________________ test_double_precision[mysql_pymysql_engine] __________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_double_precision(conn, request): 2790s if conn == "sqlite_str": 2790s pytest.skip("sqlite_str has no inspection system") 2790s 2790s conn = request.getfixturevalue(conn) 2790s 2790s from sqlalchemy import ( 2790s BigInteger, 2790s Float, 2790s Integer, 2790s ) 2790s from sqlalchemy.schema import MetaData 2790s 2790s V = 1.23456789101112131415 2790s 2790s df = DataFrame( 2790s { 2790s "f32": Series([V], dtype="float32"), 2790s "f64": Series([V], dtype="float64"), 2790s "f64_as_f32": Series([V], dtype="float64"), 2790s "i32": Series([5], dtype="int32"), 2790s "i64": Series([5], dtype="int64"), 2790s } 2790s ) 2790s 2790s assert ( 2790s > df.to_sql( 2790s name="test_dtypes", 2790s con=conn, 2790s index=False, 2790s if_exists="replace", 2790s dtype={"f64_as_f32": Float(precision=23)}, 2790s ) 2790s == 1 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3339: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s __________________ test_double_precision[mysql_pymysql_conn] ___________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_double_precision(conn, request): 2790s if conn == "sqlite_str": 2790s pytest.skip("sqlite_str has no inspection system") 2790s 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3317: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ______________ test_double_precision[postgresql_psycopg2_engine] _______________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_double_precision(conn, request): 2790s if conn == "sqlite_str": 2790s pytest.skip("sqlite_str has no inspection system") 2790s 2790s conn = request.getfixturevalue(conn) 2790s 2790s from sqlalchemy import ( 2790s BigInteger, 2790s Float, 2790s Integer, 2790s ) 2790s from sqlalchemy.schema import MetaData 2790s 2790s V = 1.23456789101112131415 2790s 2790s df = DataFrame( 2790s { 2790s "f32": Series([V], dtype="float32"), 2790s "f64": Series([V], dtype="float64"), 2790s "f64_as_f32": Series([V], dtype="float64"), 2790s "i32": Series([5], dtype="int32"), 2790s "i64": Series([5], dtype="int64"), 2790s } 2790s ) 2790s 2790s assert ( 2790s > df.to_sql( 2790s name="test_dtypes", 2790s con=conn, 2790s index=False, 2790s if_exists="replace", 2790s dtype={"f64_as_f32": Float(precision=23)}, 2790s ) 2790s == 1 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3339: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _______________ test_double_precision[postgresql_psycopg2_conn] ________________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_double_precision(conn, request): 2790s if conn == "sqlite_str": 2790s pytest.skip("sqlite_str has no inspection system") 2790s 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3317: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _____________ test_connectable_issue_example[mysql_pymysql_engine] _____________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_connectable_issue_example(conn, request): 2790s conn = request.getfixturevalue(conn) 2790s 2790s # This tests the example raised in issue 2790s # https://github.com/pandas-dev/pandas/issues/10104 2790s from sqlalchemy.engine import Engine 2790s 2790s def test_select(connection): 2790s query = "SELECT test_foo_data FROM test_foo_data" 2790s return sql.read_sql_query(query, con=connection) 2790s 2790s def test_append(connection, data): 2790s data.to_sql(name="test_foo_data", con=connection, if_exists="append") 2790s 2790s def test_connectable(conn): 2790s # https://github.com/sqlalchemy/sqlalchemy/commit/ 2790s # 00b5c10846e800304caa86549ab9da373b42fa5d#r48323973 2790s foo_data = test_select(conn) 2790s test_append(conn, foo_data) 2790s 2790s def main(connectable): 2790s if isinstance(connectable, Engine): 2790s with connectable.connect() as conn: 2790s with conn.begin(): 2790s test_connectable(conn) 2790s else: 2790s test_connectable(connectable) 2790s 2790s assert ( 2790s > DataFrame({"test_foo_data": [0, 1, 2]}).to_sql(name="test_foo_data", con=conn) 2790s == 3 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3394: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ______________ test_connectable_issue_example[mysql_pymysql_conn] ______________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_connectable_issue_example(conn, request): 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3366: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s __________ test_connectable_issue_example[postgresql_psycopg2_engine] __________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_connectable_issue_example(conn, request): 2790s conn = request.getfixturevalue(conn) 2790s 2790s # This tests the example raised in issue 2790s # https://github.com/pandas-dev/pandas/issues/10104 2790s from sqlalchemy.engine import Engine 2790s 2790s def test_select(connection): 2790s query = "SELECT test_foo_data FROM test_foo_data" 2790s return sql.read_sql_query(query, con=connection) 2790s 2790s def test_append(connection, data): 2790s data.to_sql(name="test_foo_data", con=connection, if_exists="append") 2790s 2790s def test_connectable(conn): 2790s # https://github.com/sqlalchemy/sqlalchemy/commit/ 2790s # 00b5c10846e800304caa86549ab9da373b42fa5d#r48323973 2790s foo_data = test_select(conn) 2790s test_append(conn, foo_data) 2790s 2790s def main(connectable): 2790s if isinstance(connectable, Engine): 2790s with connectable.connect() as conn: 2790s with conn.begin(): 2790s test_connectable(conn) 2790s else: 2790s test_connectable(connectable) 2790s 2790s assert ( 2790s > DataFrame({"test_foo_data": [0, 1, 2]}).to_sql(name="test_foo_data", con=conn) 2790s == 3 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3394: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ___________ test_connectable_issue_example[postgresql_psycopg2_conn] ___________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_connectable_issue_example(conn, request): 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3366: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _________ test_to_sql_with_negative_npinf[input0-mysql_pymysql_engine] _________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s input = {'foo': [inf]} 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s @pytest.mark.parametrize( 2790s "input", 2790s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 2790s ) 2790s def test_to_sql_with_negative_npinf(conn, request, input): 2790s # GH 34431 2790s 2790s df = DataFrame(input) 2790s conn_name = conn 2790s conn = request.getfixturevalue(conn) 2790s 2790s if "mysql" in conn_name: 2790s # GH 36465 2790s # The input {"foo": [-np.inf], "infe0": ["bar"]} does not raise any error 2790s # for pymysql version >= 0.10 2790s # TODO(GH#36465): remove this version check after GH 36465 is fixed 2790s pymysql = td.versioned_importorskip("pymysql") 2790s 2790s if Version(pymysql.__version__) < Version("1.0.3") and "infe0" in df.columns: 2790s mark = pytest.mark.xfail(reason="GH 36465") 2790s request.applymarker(mark) 2790s 2790s msg = "inf cannot be used with MySQL" 2790s with pytest.raises(ValueError, match=msg): 2790s > df.to_sql(name="foobar", con=conn, index=False) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3425: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s __________ test_to_sql_with_negative_npinf[input0-mysql_pymysql_conn] __________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s input = {'foo': [inf]} 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s @pytest.mark.parametrize( 2790s "input", 2790s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 2790s ) 2790s def test_to_sql_with_negative_npinf(conn, request, input): 2790s # GH 34431 2790s 2790s df = DataFrame(input) 2790s conn_name = conn 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3410: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ______ test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_engine] ______ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s input = {'foo': [inf]} 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s @pytest.mark.parametrize( 2790s "input", 2790s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 2790s ) 2790s def test_to_sql_with_negative_npinf(conn, request, input): 2790s # GH 34431 2790s 2790s df = DataFrame(input) 2790s conn_name = conn 2790s conn = request.getfixturevalue(conn) 2790s 2790s if "mysql" in conn_name: 2790s # GH 36465 2790s # The input {"foo": [-np.inf], "infe0": ["bar"]} does not raise any error 2790s # for pymysql version >= 0.10 2790s # TODO(GH#36465): remove this version check after GH 36465 is fixed 2790s pymysql = td.versioned_importorskip("pymysql") 2790s 2790s if Version(pymysql.__version__) < Version("1.0.3") and "infe0" in df.columns: 2790s mark = pytest.mark.xfail(reason="GH 36465") 2790s request.applymarker(mark) 2790s 2790s msg = "inf cannot be used with MySQL" 2790s with pytest.raises(ValueError, match=msg): 2790s df.to_sql(name="foobar", con=conn, index=False) 2790s else: 2790s > assert df.to_sql(name="foobar", con=conn, index=False) == 1 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3427: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _______ test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_conn] _______ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s input = {'foo': [inf]} 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s @pytest.mark.parametrize( 2790s "input", 2790s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 2790s ) 2790s def test_to_sql_with_negative_npinf(conn, request, input): 2790s # GH 34431 2790s 2790s df = DataFrame(input) 2790s conn_name = conn 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3410: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _________ test_to_sql_with_negative_npinf[input1-mysql_pymysql_engine] _________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s input = {'foo': [-inf]} 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s @pytest.mark.parametrize( 2790s "input", 2790s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 2790s ) 2790s def test_to_sql_with_negative_npinf(conn, request, input): 2790s # GH 34431 2790s 2790s df = DataFrame(input) 2790s conn_name = conn 2790s conn = request.getfixturevalue(conn) 2790s 2790s if "mysql" in conn_name: 2790s # GH 36465 2790s # The input {"foo": [-np.inf], "infe0": ["bar"]} does not raise any error 2790s # for pymysql version >= 0.10 2790s # TODO(GH#36465): remove this version check after GH 36465 is fixed 2790s pymysql = td.versioned_importorskip("pymysql") 2790s 2790s if Version(pymysql.__version__) < Version("1.0.3") and "infe0" in df.columns: 2790s mark = pytest.mark.xfail(reason="GH 36465") 2790s request.applymarker(mark) 2790s 2790s msg = "inf cannot be used with MySQL" 2790s with pytest.raises(ValueError, match=msg): 2790s > df.to_sql(name="foobar", con=conn, index=False) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3425: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s __________ test_to_sql_with_negative_npinf[input1-mysql_pymysql_conn] __________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s input = {'foo': [-inf]} 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s @pytest.mark.parametrize( 2790s "input", 2790s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 2790s ) 2790s def test_to_sql_with_negative_npinf(conn, request, input): 2790s # GH 34431 2790s 2790s df = DataFrame(input) 2790s conn_name = conn 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3410: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ______ test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_engine] ______ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s input = {'foo': [-inf]} 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s @pytest.mark.parametrize( 2790s "input", 2790s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 2790s ) 2790s def test_to_sql_with_negative_npinf(conn, request, input): 2790s # GH 34431 2790s 2790s df = DataFrame(input) 2790s conn_name = conn 2790s conn = request.getfixturevalue(conn) 2790s 2790s if "mysql" in conn_name: 2790s # GH 36465 2790s # The input {"foo": [-np.inf], "infe0": ["bar"]} does not raise any error 2790s # for pymysql version >= 0.10 2790s # TODO(GH#36465): remove this version check after GH 36465 is fixed 2790s pymysql = td.versioned_importorskip("pymysql") 2790s 2790s if Version(pymysql.__version__) < Version("1.0.3") and "infe0" in df.columns: 2790s mark = pytest.mark.xfail(reason="GH 36465") 2790s request.applymarker(mark) 2790s 2790s msg = "inf cannot be used with MySQL" 2790s with pytest.raises(ValueError, match=msg): 2790s df.to_sql(name="foobar", con=conn, index=False) 2790s else: 2790s > assert df.to_sql(name="foobar", con=conn, index=False) == 1 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3427: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _______ test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_conn] _______ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s input = {'foo': [-inf]} 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s @pytest.mark.parametrize( 2790s "input", 2790s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 2790s ) 2790s def test_to_sql_with_negative_npinf(conn, request, input): 2790s # GH 34431 2790s 2790s df = DataFrame(input) 2790s conn_name = conn 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3410: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _________ test_to_sql_with_negative_npinf[input2-mysql_pymysql_engine] _________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s input = {'foo': [-inf], 'infe0': ['bar']} 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s @pytest.mark.parametrize( 2790s "input", 2790s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 2790s ) 2790s def test_to_sql_with_negative_npinf(conn, request, input): 2790s # GH 34431 2790s 2790s df = DataFrame(input) 2790s conn_name = conn 2790s conn = request.getfixturevalue(conn) 2790s 2790s if "mysql" in conn_name: 2790s # GH 36465 2790s # The input {"foo": [-np.inf], "infe0": ["bar"]} does not raise any error 2790s # for pymysql version >= 0.10 2790s # TODO(GH#36465): remove this version check after GH 36465 is fixed 2790s pymysql = td.versioned_importorskip("pymysql") 2790s 2790s if Version(pymysql.__version__) < Version("1.0.3") and "infe0" in df.columns: 2790s mark = pytest.mark.xfail(reason="GH 36465") 2790s request.applymarker(mark) 2790s 2790s msg = "inf cannot be used with MySQL" 2790s with pytest.raises(ValueError, match=msg): 2790s > df.to_sql(name="foobar", con=conn, index=False) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3425: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s __________ test_to_sql_with_negative_npinf[input2-mysql_pymysql_conn] __________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s input = {'foo': [-inf], 'infe0': ['bar']} 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s @pytest.mark.parametrize( 2790s "input", 2790s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 2790s ) 2790s def test_to_sql_with_negative_npinf(conn, request, input): 2790s # GH 34431 2790s 2790s df = DataFrame(input) 2790s conn_name = conn 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3410: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ______ test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_engine] ______ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s input = {'foo': [-inf], 'infe0': ['bar']} 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s @pytest.mark.parametrize( 2790s "input", 2790s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 2790s ) 2790s def test_to_sql_with_negative_npinf(conn, request, input): 2790s # GH 34431 2790s 2790s df = DataFrame(input) 2790s conn_name = conn 2790s conn = request.getfixturevalue(conn) 2790s 2790s if "mysql" in conn_name: 2790s # GH 36465 2790s # The input {"foo": [-np.inf], "infe0": ["bar"]} does not raise any error 2790s # for pymysql version >= 0.10 2790s # TODO(GH#36465): remove this version check after GH 36465 is fixed 2790s pymysql = td.versioned_importorskip("pymysql") 2790s 2790s if Version(pymysql.__version__) < Version("1.0.3") and "infe0" in df.columns: 2790s mark = pytest.mark.xfail(reason="GH 36465") 2790s request.applymarker(mark) 2790s 2790s msg = "inf cannot be used with MySQL" 2790s with pytest.raises(ValueError, match=msg): 2790s df.to_sql(name="foobar", con=conn, index=False) 2790s else: 2790s > assert df.to_sql(name="foobar", con=conn, index=False) == 1 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3427: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _______ test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_conn] _______ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s input = {'foo': [-inf], 'infe0': ['bar']} 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s @pytest.mark.parametrize( 2790s "input", 2790s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 2790s ) 2790s def test_to_sql_with_negative_npinf(conn, request, input): 2790s # GH 34431 2790s 2790s df = DataFrame(input) 2790s conn_name = conn 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3410: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s __________________ test_temporary_table[mysql_pymysql_engine] __________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_temporary_table(conn, request): 2790s if conn == "sqlite_str": 2790s pytest.skip("test does not work with str connection") 2790s 2790s conn = request.getfixturevalue(conn) 2790s 2790s from sqlalchemy import ( 2790s Column, 2790s Integer, 2790s Unicode, 2790s select, 2790s ) 2790s from sqlalchemy.orm import ( 2790s Session, 2790s declarative_base, 2790s ) 2790s 2790s test_data = "Hello, World!" 2790s expected = DataFrame({"spam": [test_data]}) 2790s Base = declarative_base() 2790s 2790s class Temporary(Base): 2790s __tablename__ = "temp_test" 2790s __table_args__ = {"prefixes": ["TEMPORARY"]} 2790s id = Column(Integer, primary_key=True) 2790s spam = Column(Unicode(30), nullable=False) 2790s 2790s with Session(conn) as session: 2790s with session.begin(): 2790s > conn = session.connection() 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3462: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/orm/session.py:2094: in connection 2790s return self._connection_for_bind( 2790s /usr/lib/python3/dist-packages/sqlalchemy/orm/session.py:2110: in _connection_for_bind 2790s return trans._connection_for_bind(engine, execution_options) 2790s :2: in _connection_for_bind 2790s ??? 2790s /usr/lib/python3/dist-packages/sqlalchemy/orm/state_changes.py:139: in _go 2790s ret_value = fn(self, *arg, **kw) 2790s /usr/lib/python3/dist-packages/sqlalchemy/orm/session.py:1189: in _connection_for_bind 2790s conn = bind.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ___________________ test_temporary_table[mysql_pymysql_conn] ___________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_temporary_table(conn, request): 2790s if conn == "sqlite_str": 2790s pytest.skip("test does not work with str connection") 2790s 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3437: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _______________ test_temporary_table[postgresql_psycopg2_engine] _______________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_temporary_table(conn, request): 2790s if conn == "sqlite_str": 2790s pytest.skip("test does not work with str connection") 2790s 2790s conn = request.getfixturevalue(conn) 2790s 2790s from sqlalchemy import ( 2790s Column, 2790s Integer, 2790s Unicode, 2790s select, 2790s ) 2790s from sqlalchemy.orm import ( 2790s Session, 2790s declarative_base, 2790s ) 2790s 2790s test_data = "Hello, World!" 2790s expected = DataFrame({"spam": [test_data]}) 2790s Base = declarative_base() 2790s 2790s class Temporary(Base): 2790s __tablename__ = "temp_test" 2790s __table_args__ = {"prefixes": ["TEMPORARY"]} 2790s id = Column(Integer, primary_key=True) 2790s spam = Column(Unicode(30), nullable=False) 2790s 2790s with Session(conn) as session: 2790s with session.begin(): 2790s > conn = session.connection() 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3462: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/orm/session.py:2094: in connection 2790s return self._connection_for_bind( 2790s /usr/lib/python3/dist-packages/sqlalchemy/orm/session.py:2110: in _connection_for_bind 2790s return trans._connection_for_bind(engine, execution_options) 2790s :2: in _connection_for_bind 2790s ??? 2790s /usr/lib/python3/dist-packages/sqlalchemy/orm/state_changes.py:139: in _go 2790s ret_value = fn(self, *arg, **kw) 2790s /usr/lib/python3/dist-packages/sqlalchemy/orm/session.py:1189: in _connection_for_bind 2790s conn = bind.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ________________ test_temporary_table[postgresql_psycopg2_conn] ________________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_temporary_table(conn, request): 2790s if conn == "sqlite_str": 2790s pytest.skip("test does not work with str connection") 2790s 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3437: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s __________________ test_invalid_engine[mysql_pymysql_engine] ___________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s test_frame1 = index A B C D 2790s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2790s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s def test_invalid_engine(conn, request, test_frame1): 2790s if conn == "sqlite_buildin" or "adbc" in conn: 2790s request.applymarker( 2790s pytest.mark.xfail( 2790s reason="SQLiteDatabase/ADBCDatabase does not raise for bad engine" 2790s ) 2790s ) 2790s 2790s conn = request.getfixturevalue(conn) 2790s msg = "engine must be one of 'auto', 'sqlalchemy'" 2790s > with pandasSQL_builder(conn) as pandasSQL: 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3481: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ___________________ test_invalid_engine[mysql_pymysql_conn] ____________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s test_frame1 = index A B C D 2790s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2790s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s def test_invalid_engine(conn, request, test_frame1): 2790s if conn == "sqlite_buildin" or "adbc" in conn: 2790s request.applymarker( 2790s pytest.mark.xfail( 2790s reason="SQLiteDatabase/ADBCDatabase does not raise for bad engine" 2790s ) 2790s ) 2790s 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3479: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _______________ test_invalid_engine[postgresql_psycopg2_engine] ________________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s test_frame1 = index A B C D 2790s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2790s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s def test_invalid_engine(conn, request, test_frame1): 2790s if conn == "sqlite_buildin" or "adbc" in conn: 2790s request.applymarker( 2790s pytest.mark.xfail( 2790s reason="SQLiteDatabase/ADBCDatabase does not raise for bad engine" 2790s ) 2790s ) 2790s 2790s conn = request.getfixturevalue(conn) 2790s msg = "engine must be one of 'auto', 'sqlalchemy'" 2790s > with pandasSQL_builder(conn) as pandasSQL: 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3481: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ________________ test_invalid_engine[postgresql_psycopg2_conn] _________________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s test_frame1 = index A B C D 2790s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2790s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s def test_invalid_engine(conn, request, test_frame1): 2790s if conn == "sqlite_buildin" or "adbc" in conn: 2790s request.applymarker( 2790s pytest.mark.xfail( 2790s reason="SQLiteDatabase/ADBCDatabase does not raise for bad engine" 2790s ) 2790s ) 2790s 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3479: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ______________ test_to_sql_with_sql_engine[mysql_pymysql_engine] _______________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s test_frame1 = index A B C D 2790s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2790s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s def test_to_sql_with_sql_engine(conn, request, test_frame1): 2790s """`to_sql` with the `engine` param""" 2790s # mostly copied from this class's `_to_sql()` method 2790s conn = request.getfixturevalue(conn) 2790s > with pandasSQL_builder(conn) as pandasSQL: 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3491: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _______________ test_to_sql_with_sql_engine[mysql_pymysql_conn] ________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s test_frame1 = index A B C D 2790s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2790s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s def test_to_sql_with_sql_engine(conn, request, test_frame1): 2790s """`to_sql` with the `engine` param""" 2790s # mostly copied from this class's `_to_sql()` method 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3490: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ___________ test_to_sql_with_sql_engine[postgresql_psycopg2_engine] ____________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s test_frame1 = index A B C D 2790s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2790s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s def test_to_sql_with_sql_engine(conn, request, test_frame1): 2790s """`to_sql` with the `engine` param""" 2790s # mostly copied from this class's `_to_sql()` method 2790s conn = request.getfixturevalue(conn) 2790s > with pandasSQL_builder(conn) as pandasSQL: 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3491: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ____________ test_to_sql_with_sql_engine[postgresql_psycopg2_conn] _____________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s test_frame1 = index A B C D 2790s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2790s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s def test_to_sql_with_sql_engine(conn, request, test_frame1): 2790s """`to_sql` with the `engine` param""" 2790s # mostly copied from this class's `_to_sql()` method 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3490: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ________________ test_options_sqlalchemy[mysql_pymysql_engine] _________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s test_frame1 = index A B C D 2790s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2790s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_options_sqlalchemy(conn, request, test_frame1): 2790s # use the set option 2790s conn = request.getfixturevalue(conn) 2790s with pd.option_context("io.sql.engine", "sqlalchemy"): 2790s > with pandasSQL_builder(conn) as pandasSQL: 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3506: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _________________ test_options_sqlalchemy[mysql_pymysql_conn] __________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s test_frame1 = index A B C D 2790s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2790s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_options_sqlalchemy(conn, request, test_frame1): 2790s # use the set option 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3504: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _____________ test_options_sqlalchemy[postgresql_psycopg2_engine] ______________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s test_frame1 = index A B C D 2790s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2790s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_options_sqlalchemy(conn, request, test_frame1): 2790s # use the set option 2790s conn = request.getfixturevalue(conn) 2790s with pd.option_context("io.sql.engine", "sqlalchemy"): 2790s > with pandasSQL_builder(conn) as pandasSQL: 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3506: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ______________ test_options_sqlalchemy[postgresql_psycopg2_conn] _______________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s test_frame1 = index A B C D 2790s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2790s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2790s 2790s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2790s def test_options_sqlalchemy(conn, request, test_frame1): 2790s # use the set option 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3504: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ___________________ test_options_auto[mysql_pymysql_engine] ____________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s test_frame1 = index A B C D 2790s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2790s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s def test_options_auto(conn, request, test_frame1): 2790s # use the set option 2790s conn = request.getfixturevalue(conn) 2790s with pd.option_context("io.sql.engine", "auto"): 2790s > with pandasSQL_builder(conn) as pandasSQL: 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3521: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ____________________ test_options_auto[mysql_pymysql_conn] _____________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s test_frame1 = index A B C D 2790s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2790s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s def test_options_auto(conn, request, test_frame1): 2790s # use the set option 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3519: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ________________ test_options_auto[postgresql_psycopg2_engine] _________________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s test_frame1 = index A B C D 2790s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2790s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s def test_options_auto(conn, request, test_frame1): 2790s # use the set option 2790s conn = request.getfixturevalue(conn) 2790s with pd.option_context("io.sql.engine", "auto"): 2790s > with pandasSQL_builder(conn) as pandasSQL: 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3521: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _________________ test_options_auto[postgresql_psycopg2_conn] __________________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s test_frame1 = index A B C D 2790s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2790s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s def test_options_auto(conn, request, test_frame1): 2790s # use the set option 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3519: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql-mysql_pymysql_engine] _ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 2790s dtype_backend_data = a b c d e f g h 2790s 0 1 1 1.5 1.5 True True a a 2790s 1 2 2.0 False False b b 2790s 2 3 3 2.5 2.5 None True c None 2790s dtype_backend_expected = .func at 0xdffec668> 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2790s def test_read_sql_dtype_backend( 2790s conn, 2790s request, 2790s string_storage, 2790s func, 2790s dtype_backend, 2790s dtype_backend_data, 2790s dtype_backend_expected, 2790s ): 2790s # GH#50048 2790s conn_name = conn 2790s conn = request.getfixturevalue(conn) 2790s table = "test" 2790s df = dtype_backend_data 2790s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3567: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql-mysql_pymysql_conn] _ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 2790s dtype_backend_data = a b c d e f g h 2790s 0 1 1 1.5 1.5 True True a a 2790s 1 2 2.0 False False b b 2790s 2 3 3 2.5 2.5 None True c None 2790s dtype_backend_expected = .func at 0xdffec6b8> 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2790s def test_read_sql_dtype_backend( 2790s conn, 2790s request, 2790s string_storage, 2790s func, 2790s dtype_backend, 2790s dtype_backend_data, 2790s dtype_backend_expected, 2790s ): 2790s # GH#50048 2790s conn_name = conn 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3564: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql-postgresql_psycopg2_engine] _ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 2790s dtype_backend_data = a b c d e f g h 2790s 0 1 1 1.5 1.5 True True a a 2790s 1 2 2.0 False False b b 2790s 2 3 3 2.5 2.5 None True c None 2790s dtype_backend_expected = .func at 0xdffec708> 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2790s def test_read_sql_dtype_backend( 2790s conn, 2790s request, 2790s string_storage, 2790s func, 2790s dtype_backend, 2790s dtype_backend_data, 2790s dtype_backend_expected, 2790s ): 2790s # GH#50048 2790s conn_name = conn 2790s conn = request.getfixturevalue(conn) 2790s table = "test" 2790s df = dtype_backend_data 2790s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3567: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql-postgresql_psycopg2_conn] _ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 2790s dtype_backend_data = a b c d e f g h 2790s 0 1 1 1.5 1.5 True True a a 2790s 1 2 2.0 False False b b 2790s 2 3 3 2.5 2.5 None True c None 2790s dtype_backend_expected = .func at 0xdffec7a8> 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2790s def test_read_sql_dtype_backend( 2790s conn, 2790s request, 2790s string_storage, 2790s func, 2790s dtype_backend, 2790s dtype_backend_data, 2790s dtype_backend_expected, 2790s ): 2790s # GH#50048 2790s conn_name = conn 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3564: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-mysql_pymysql_engine] _ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s string_storage = 'python', func = 'read_sql_query' 2790s dtype_backend = 'numpy_nullable' 2790s dtype_backend_data = a b c d e f g h 2790s 0 1 1 1.5 1.5 True True a a 2790s 1 2 2.0 False False b b 2790s 2 3 3 2.5 2.5 None True c None 2790s dtype_backend_expected = .func at 0xdffecac8> 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2790s def test_read_sql_dtype_backend( 2790s conn, 2790s request, 2790s string_storage, 2790s func, 2790s dtype_backend, 2790s dtype_backend_data, 2790s dtype_backend_expected, 2790s ): 2790s # GH#50048 2790s conn_name = conn 2790s conn = request.getfixturevalue(conn) 2790s table = "test" 2790s df = dtype_backend_data 2790s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3567: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-mysql_pymysql_conn] _ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s string_storage = 'python', func = 'read_sql_query' 2790s dtype_backend = 'numpy_nullable' 2790s dtype_backend_data = a b c d e f g h 2790s 0 1 1 1.5 1.5 True True a a 2790s 1 2 2.0 False False b b 2790s 2 3 3 2.5 2.5 None True c None 2790s dtype_backend_expected = .func at 0xdffecb68> 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2790s def test_read_sql_dtype_backend( 2790s conn, 2790s request, 2790s string_storage, 2790s func, 2790s dtype_backend, 2790s dtype_backend_data, 2790s dtype_backend_expected, 2790s ): 2790s # GH#50048 2790s conn_name = conn 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3564: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-postgresql_psycopg2_engine] _ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s string_storage = 'python', func = 'read_sql_query' 2790s dtype_backend = 'numpy_nullable' 2790s dtype_backend_data = a b c d e f g h 2790s 0 1 1 1.5 1.5 True True a a 2790s 1 2 2.0 False False b b 2790s 2 3 3 2.5 2.5 None True c None 2790s dtype_backend_expected = .func at 0xdffecc08> 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2790s def test_read_sql_dtype_backend( 2790s conn, 2790s request, 2790s string_storage, 2790s func, 2790s dtype_backend, 2790s dtype_backend_data, 2790s dtype_backend_expected, 2790s ): 2790s # GH#50048 2790s conn_name = conn 2790s conn = request.getfixturevalue(conn) 2790s table = "test" 2790s df = dtype_backend_data 2790s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3567: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-postgresql_psycopg2_conn] _ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s string_storage = 'python', func = 'read_sql_query' 2790s dtype_backend = 'numpy_nullable' 2790s dtype_backend_data = a b c d e f g h 2790s 0 1 1 1.5 1.5 True True a a 2790s 1 2 2.0 False False b b 2790s 2 3 3 2.5 2.5 None True c None 2790s dtype_backend_expected = .func at 0xdffecc58> 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2790s def test_read_sql_dtype_backend( 2790s conn, 2790s request, 2790s string_storage, 2790s func, 2790s dtype_backend, 2790s dtype_backend_data, 2790s dtype_backend_expected, 2790s ): 2790s # GH#50048 2790s conn_name = conn 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3564: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-mysql_pymysql_engine] _ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 2790s dtype_backend_data = a b c d e f g h 2790s 0 1 1 1.5 1.5 True True a a 2790s 1 2 2.0 False False b b 2790s 2 3 3 2.5 2.5 None True c None 2790s dtype_backend_expected = .func at 0xdfbd9a78> 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 2790s def test_read_sql_dtype_backend_table( 2790s conn, 2790s request, 2790s string_storage, 2790s func, 2790s dtype_backend, 2790s dtype_backend_data, 2790s dtype_backend_expected, 2790s ): 2790s if "sqlite" in conn and "adbc" not in conn: 2790s request.applymarker( 2790s pytest.mark.xfail( 2790s reason=( 2790s "SQLite actually returns proper boolean values via " 2790s "read_sql_table, but before pytest refactor was skipped" 2790s ) 2790s ) 2790s ) 2790s # GH#50048 2790s conn_name = conn 2790s conn = request.getfixturevalue(conn) 2790s table = "test" 2790s df = dtype_backend_data 2790s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3619: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-mysql_pymysql_conn] _ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 2790s dtype_backend_data = a b c d e f g h 2790s 0 1 1 1.5 1.5 True True a a 2790s 1 2 2.0 False False b b 2790s 2 3 3 2.5 2.5 None True c None 2790s dtype_backend_expected = .func at 0xdfbd9ac8> 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 2790s def test_read_sql_dtype_backend_table( 2790s conn, 2790s request, 2790s string_storage, 2790s func, 2790s dtype_backend, 2790s dtype_backend_data, 2790s dtype_backend_expected, 2790s ): 2790s if "sqlite" in conn and "adbc" not in conn: 2790s request.applymarker( 2790s pytest.mark.xfail( 2790s reason=( 2790s "SQLite actually returns proper boolean values via " 2790s "read_sql_table, but before pytest refactor was skipped" 2790s ) 2790s ) 2790s ) 2790s # GH#50048 2790s conn_name = conn 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3616: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-postgresql_psycopg2_engine] _ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 2790s dtype_backend_data = a b c d e f g h 2790s 0 1 1 1.5 1.5 True True a a 2790s 1 2 2.0 False False b b 2790s 2 3 3 2.5 2.5 None True c None 2790s dtype_backend_expected = .func at 0xdfbd9b18> 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 2790s def test_read_sql_dtype_backend_table( 2790s conn, 2790s request, 2790s string_storage, 2790s func, 2790s dtype_backend, 2790s dtype_backend_data, 2790s dtype_backend_expected, 2790s ): 2790s if "sqlite" in conn and "adbc" not in conn: 2790s request.applymarker( 2790s pytest.mark.xfail( 2790s reason=( 2790s "SQLite actually returns proper boolean values via " 2790s "read_sql_table, but before pytest refactor was skipped" 2790s ) 2790s ) 2790s ) 2790s # GH#50048 2790s conn_name = conn 2790s conn = request.getfixturevalue(conn) 2790s table = "test" 2790s df = dtype_backend_data 2790s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3619: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-postgresql_psycopg2_conn] _ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 2790s dtype_backend_data = a b c d e f g h 2790s 0 1 1 1.5 1.5 True True a a 2790s 1 2 2.0 False False b b 2790s 2 3 3 2.5 2.5 None True c None 2790s dtype_backend_expected = .func at 0xdfbd9bb8> 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 2790s def test_read_sql_dtype_backend_table( 2790s conn, 2790s request, 2790s string_storage, 2790s func, 2790s dtype_backend, 2790s dtype_backend_data, 2790s dtype_backend_expected, 2790s ): 2790s if "sqlite" in conn and "adbc" not in conn: 2790s request.applymarker( 2790s pytest.mark.xfail( 2790s reason=( 2790s "SQLite actually returns proper boolean values via " 2790s "read_sql_table, but before pytest refactor was skipped" 2790s ) 2790s ) 2790s ) 2790s # GH#50048 2790s conn_name = conn 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3616: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-mysql_pymysql_engine] _ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s string_storage = 'python', func = 'read_sql_table' 2790s dtype_backend = 'numpy_nullable' 2790s dtype_backend_data = a b c d e f g h 2790s 0 1 1 1.5 1.5 True True a a 2790s 1 2 2.0 False False b b 2790s 2 3 3 2.5 2.5 None True c None 2790s dtype_backend_expected = .func at 0xdfbd9ed8> 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 2790s def test_read_sql_dtype_backend_table( 2790s conn, 2790s request, 2790s string_storage, 2790s func, 2790s dtype_backend, 2790s dtype_backend_data, 2790s dtype_backend_expected, 2790s ): 2790s if "sqlite" in conn and "adbc" not in conn: 2790s request.applymarker( 2790s pytest.mark.xfail( 2790s reason=( 2790s "SQLite actually returns proper boolean values via " 2790s "read_sql_table, but before pytest refactor was skipped" 2790s ) 2790s ) 2790s ) 2790s # GH#50048 2790s conn_name = conn 2790s conn = request.getfixturevalue(conn) 2790s table = "test" 2790s df = dtype_backend_data 2790s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3619: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-mysql_pymysql_conn] _ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s string_storage = 'python', func = 'read_sql_table' 2790s dtype_backend = 'numpy_nullable' 2790s dtype_backend_data = a b c d e f g h 2790s 0 1 1 1.5 1.5 True True a a 2790s 1 2 2.0 False False b b 2790s 2 3 3 2.5 2.5 None True c None 2790s dtype_backend_expected = .func at 0xdfbd9ed8> 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 2790s def test_read_sql_dtype_backend_table( 2790s conn, 2790s request, 2790s string_storage, 2790s func, 2790s dtype_backend, 2790s dtype_backend_data, 2790s dtype_backend_expected, 2790s ): 2790s if "sqlite" in conn and "adbc" not in conn: 2790s request.applymarker( 2790s pytest.mark.xfail( 2790s reason=( 2790s "SQLite actually returns proper boolean values via " 2790s "read_sql_table, but before pytest refactor was skipped" 2790s ) 2790s ) 2790s ) 2790s # GH#50048 2790s conn_name = conn 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3616: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-postgresql_psycopg2_engine] _ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s string_storage = 'python', func = 'read_sql_table' 2790s dtype_backend = 'numpy_nullable' 2790s dtype_backend_data = a b c d e f g h 2790s 0 1 1 1.5 1.5 True True a a 2790s 1 2 2.0 False False b b 2790s 2 3 3 2.5 2.5 None True c None 2790s dtype_backend_expected = .func at 0xdfbd9f78> 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 2790s def test_read_sql_dtype_backend_table( 2790s conn, 2790s request, 2790s string_storage, 2790s func, 2790s dtype_backend, 2790s dtype_backend_data, 2790s dtype_backend_expected, 2790s ): 2790s if "sqlite" in conn and "adbc" not in conn: 2790s request.applymarker( 2790s pytest.mark.xfail( 2790s reason=( 2790s "SQLite actually returns proper boolean values via " 2790s "read_sql_table, but before pytest refactor was skipped" 2790s ) 2790s ) 2790s ) 2790s # GH#50048 2790s conn_name = conn 2790s conn = request.getfixturevalue(conn) 2790s table = "test" 2790s df = dtype_backend_data 2790s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3619: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-postgresql_psycopg2_conn] _ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s string_storage = 'python', func = 'read_sql_table' 2790s dtype_backend = 'numpy_nullable' 2790s dtype_backend_data = a b c d e f g h 2790s 0 1 1 1.5 1.5 True True a a 2790s 1 2 2.0 False False b b 2790s 2 3 3 2.5 2.5 None True c None 2790s dtype_backend_expected = .func at 0xdfbef028> 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 2790s def test_read_sql_dtype_backend_table( 2790s conn, 2790s request, 2790s string_storage, 2790s func, 2790s dtype_backend, 2790s dtype_backend_data, 2790s dtype_backend_expected, 2790s ): 2790s if "sqlite" in conn and "adbc" not in conn: 2790s request.applymarker( 2790s pytest.mark.xfail( 2790s reason=( 2790s "SQLite actually returns proper boolean values via " 2790s "read_sql_table, but before pytest refactor was skipped" 2790s ) 2790s ) 2790s ) 2790s # GH#50048 2790s conn_name = conn 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3616: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ___ test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_engine] ___ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s func = 'read_sql' 2790s dtype_backend_data = a b c d e f g h 2790s 0 1 1 1.5 1.5 True True a a 2790s 1 2 2.0 False False b b 2790s 2 3 3 2.5 2.5 None True c None 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 2790s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 2790s conn = request.getfixturevalue(conn) 2790s table = "test" 2790s df = dtype_backend_data 2790s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3648: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ____ test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_conn] ____ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s func = 'read_sql' 2790s dtype_backend_data = a b c d e f g h 2790s 0 1 1 1.5 1.5 True True a a 2790s 1 2 2.0 False False b b 2790s 2 3 3 2.5 2.5 None True c None 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 2790s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3645: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _ test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_engine] _ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s func = 'read_sql' 2790s dtype_backend_data = a b c d e f g h 2790s 0 1 1 1.5 1.5 True True a a 2790s 1 2 2.0 False False b b 2790s 2 3 3 2.5 2.5 None True c None 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 2790s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 2790s conn = request.getfixturevalue(conn) 2790s table = "test" 2790s df = dtype_backend_data 2790s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3648: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _ test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_conn] _ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s func = 'read_sql' 2790s dtype_backend_data = a b c d e f g h 2790s 0 1 1 1.5 1.5 True True a a 2790s 1 2 2.0 False False b b 2790s 2 3 3 2.5 2.5 None True c None 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 2790s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3645: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _ test_read_sql_invalid_dtype_backend_table[read_sql_table-mysql_pymysql_engine] _ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s func = 'read_sql_table' 2790s dtype_backend_data = a b c d e f g h 2790s 0 1 1 1.5 1.5 True True a a 2790s 1 2 2.0 False False b b 2790s 2 3 3 2.5 2.5 None True c None 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 2790s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 2790s conn = request.getfixturevalue(conn) 2790s table = "test" 2790s df = dtype_backend_data 2790s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3648: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _ test_read_sql_invalid_dtype_backend_table[read_sql_table-mysql_pymysql_conn] _ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s func = 'read_sql_table' 2790s dtype_backend_data = a b c d e f g h 2790s 0 1 1 1.5 1.5 True True a a 2790s 1 2 2.0 False False b b 2790s 2 3 3 2.5 2.5 None True c None 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 2790s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3645: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _ test_read_sql_invalid_dtype_backend_table[read_sql_table-postgresql_psycopg2_engine] _ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s func = 'read_sql_table' 2790s dtype_backend_data = a b c d e f g h 2790s 0 1 1 1.5 1.5 True True a a 2790s 1 2 2.0 False False b b 2790s 2 3 3 2.5 2.5 None True c None 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 2790s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 2790s conn = request.getfixturevalue(conn) 2790s table = "test" 2790s df = dtype_backend_data 2790s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3648: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _ test_read_sql_invalid_dtype_backend_table[read_sql_table-postgresql_psycopg2_conn] _ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s func = 'read_sql_table' 2790s dtype_backend_data = a b c d e f g h 2790s 0 1 1 1.5 1.5 True True a a 2790s 1 2 2.0 False False b b 2790s 2 3 3 2.5 2.5 None True c None 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 2790s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3645: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _ test_read_sql_invalid_dtype_backend_table[read_sql_query-mysql_pymysql_engine] _ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s func = 'read_sql_query' 2790s dtype_backend_data = a b c d e f g h 2790s 0 1 1 1.5 1.5 True True a a 2790s 1 2 2.0 False False b b 2790s 2 3 3 2.5 2.5 None True c None 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 2790s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 2790s conn = request.getfixturevalue(conn) 2790s table = "test" 2790s df = dtype_backend_data 2790s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3648: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _ test_read_sql_invalid_dtype_backend_table[read_sql_query-mysql_pymysql_conn] _ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s func = 'read_sql_query' 2790s dtype_backend_data = a b c d e f g h 2790s 0 1 1 1.5 1.5 True True a a 2790s 1 2 2.0 False False b b 2790s 2 3 3 2.5 2.5 None True c None 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 2790s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3645: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _ test_read_sql_invalid_dtype_backend_table[read_sql_query-postgresql_psycopg2_engine] _ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s func = 'read_sql_query' 2790s dtype_backend_data = a b c d e f g h 2790s 0 1 1 1.5 1.5 True True a a 2790s 1 2 2.0 False False b b 2790s 2 3 3 2.5 2.5 None True c None 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 2790s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 2790s conn = request.getfixturevalue(conn) 2790s table = "test" 2790s df = dtype_backend_data 2790s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3648: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _ test_read_sql_invalid_dtype_backend_table[read_sql_query-postgresql_psycopg2_conn] _ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s func = 'read_sql_query' 2790s dtype_backend_data = a b c d e f g h 2790s 0 1 1 1.5 1.5 True True a a 2790s 1 2 2.0 False False b b 2790s 2 3 3 2.5 2.5 None True c None 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 2790s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3645: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ______________ test_chunksize_empty_dtypes[mysql_pymysql_engine] _______________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s def test_chunksize_empty_dtypes(conn, request): 2790s # GH#50245 2790s if "adbc" in conn: 2790s request.node.add_marker( 2790s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2790s ) 2790s conn = request.getfixturevalue(conn) 2790s dtypes = {"a": "int64", "b": "object"} 2790s df = DataFrame(columns=["a", "b"]).astype(dtypes) 2790s expected = df.copy() 2790s > df.to_sql(name="test", con=conn, index=False, if_exists="replace") 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3741: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _______________ test_chunksize_empty_dtypes[mysql_pymysql_conn] ________________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s def test_chunksize_empty_dtypes(conn, request): 2790s # GH#50245 2790s if "adbc" in conn: 2790s request.node.add_marker( 2790s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2790s ) 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3737: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ___________ test_chunksize_empty_dtypes[postgresql_psycopg2_engine] ____________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s def test_chunksize_empty_dtypes(conn, request): 2790s # GH#50245 2790s if "adbc" in conn: 2790s request.node.add_marker( 2790s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2790s ) 2790s conn = request.getfixturevalue(conn) 2790s dtypes = {"a": "int64", "b": "object"} 2790s df = DataFrame(columns=["a", "b"]).astype(dtypes) 2790s expected = df.copy() 2790s > df.to_sql(name="test", con=conn, index=False, if_exists="replace") 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3741: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ____________ test_chunksize_empty_dtypes[postgresql_psycopg2_conn] _____________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s def test_chunksize_empty_dtypes(conn, request): 2790s # GH#50245 2790s if "adbc" in conn: 2790s request.node.add_marker( 2790s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2790s ) 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3737: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ___ test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_engine] ___ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s func = 'read_sql', dtype_backend = 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2790s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2790s def test_read_sql_dtype(conn, request, func, dtype_backend): 2790s # GH#50797 2790s conn = request.getfixturevalue(conn) 2790s table = "test" 2790s df = DataFrame({"a": [1, 2, 3], "b": 5}) 2790s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ____ test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_conn] ____ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s func = 'read_sql', dtype_backend = 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2790s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2790s def test_read_sql_dtype(conn, request, func, dtype_backend): 2790s # GH#50797 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _ test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_engine] _ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s func = 'read_sql', dtype_backend = 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2790s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2790s def test_read_sql_dtype(conn, request, func, dtype_backend): 2790s # GH#50797 2790s conn = request.getfixturevalue(conn) 2790s table = "test" 2790s df = DataFrame({"a": [1, 2, 3], "b": 5}) 2790s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _ test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_conn] _ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s func = 'read_sql', dtype_backend = 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2790s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2790s def test_read_sql_dtype(conn, request, func, dtype_backend): 2790s # GH#50797 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ______ test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_engine] _______ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s func = 'read_sql', dtype_backend = 'numpy_nullable' 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2790s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2790s def test_read_sql_dtype(conn, request, func, dtype_backend): 2790s # GH#50797 2790s conn = request.getfixturevalue(conn) 2790s table = "test" 2790s df = DataFrame({"a": [1, 2, 3], "b": 5}) 2790s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _______ test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_conn] ________ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s func = 'read_sql', dtype_backend = 'numpy_nullable' 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2790s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2790s def test_read_sql_dtype(conn, request, func, dtype_backend): 2790s # GH#50797 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ___ test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_engine] ____ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s func = 'read_sql', dtype_backend = 'numpy_nullable' 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2790s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2790s def test_read_sql_dtype(conn, request, func, dtype_backend): 2790s # GH#50797 2790s conn = request.getfixturevalue(conn) 2790s table = "test" 2790s df = DataFrame({"a": [1, 2, 3], "b": 5}) 2790s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ____ test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_conn] _____ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s func = 'read_sql', dtype_backend = 'numpy_nullable' 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2790s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2790s def test_read_sql_dtype(conn, request, func, dtype_backend): 2790s # GH#50797 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _ test_read_sql_dtype[read_sql_query-_NoDefault.no_default-mysql_pymysql_engine] _ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s func = 'read_sql_query', dtype_backend = 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2790s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2790s def test_read_sql_dtype(conn, request, func, dtype_backend): 2790s # GH#50797 2790s conn = request.getfixturevalue(conn) 2790s table = "test" 2790s df = DataFrame({"a": [1, 2, 3], "b": 5}) 2790s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _ test_read_sql_dtype[read_sql_query-_NoDefault.no_default-mysql_pymysql_conn] _ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s func = 'read_sql_query', dtype_backend = 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2790s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2790s def test_read_sql_dtype(conn, request, func, dtype_backend): 2790s # GH#50797 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _ test_read_sql_dtype[read_sql_query-_NoDefault.no_default-postgresql_psycopg2_engine] _ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s func = 'read_sql_query', dtype_backend = 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2790s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2790s def test_read_sql_dtype(conn, request, func, dtype_backend): 2790s # GH#50797 2790s conn = request.getfixturevalue(conn) 2790s table = "test" 2790s df = DataFrame({"a": [1, 2, 3], "b": 5}) 2790s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _ test_read_sql_dtype[read_sql_query-_NoDefault.no_default-postgresql_psycopg2_conn] _ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s func = 'read_sql_query', dtype_backend = 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2790s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2790s def test_read_sql_dtype(conn, request, func, dtype_backend): 2790s # GH#50797 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s ___ test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_engine] ____ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2790s request = > 2790s func = 'read_sql_query', dtype_backend = 'numpy_nullable' 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2790s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2790s def test_read_sql_dtype(conn, request, func, dtype_backend): 2790s # GH#50797 2790s conn = request.getfixturevalue(conn) 2790s table = "test" 2790s df = DataFrame({"a": [1, 2, 3], "b": 5}) 2790s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s ____ test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_conn] _____ 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s > sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3.13/socket.py:864: in create_connection 2790s raise exceptions[0] 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s address = ('localhost', 3306), timeout = 10, source_address = None 2790s 2790s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2790s source_address=None, *, all_errors=False): 2790s """Connect to *address* and return the socket object. 2790s 2790s Convenience function. Connect to *address* (a 2-tuple ``(host, 2790s port)``) and return the socket object. Passing the optional 2790s *timeout* parameter will set the timeout on the socket instance 2790s before attempting to connect. If no *timeout* is supplied, the 2790s global default timeout setting returned by :func:`getdefaulttimeout` 2790s is used. If *source_address* is set it must be a tuple of (host, port) 2790s for the socket to bind as a source address before making the connection. 2790s A host of '' or port 0 tells the OS to use the default. When a connection 2790s cannot be created, raises the last error if *all_errors* is False, 2790s and an ExceptionGroup of all errors if *all_errors* is True. 2790s """ 2790s 2790s host, port = address 2790s exceptions = [] 2790s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2790s af, socktype, proto, canonname, sa = res 2790s sock = None 2790s try: 2790s sock = socket(af, socktype, proto) 2790s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2790s sock.settimeout(timeout) 2790s if source_address: 2790s sock.bind(source_address) 2790s > sock.connect(sa) 2790s E ConnectionRefusedError: [Errno 111] Connection refused 2790s 2790s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2790s 2790s During handling of the above exception, another exception occurred: 2790s 2790s self = 2790s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2790s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'mysql_pymysql_conn' 2790s request = > 2790s func = 'read_sql_query', dtype_backend = 'numpy_nullable' 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2790s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2790s def test_read_sql_dtype(conn, request, func, dtype_backend): 2790s # GH#50797 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2790s with mysql_pymysql_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2790s self.connect() 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s self = , sock = None 2790s 2790s def connect(self, sock=None): 2790s self._closed = False 2790s try: 2790s if sock is None: 2790s if self.unix_socket: 2790s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2790s sock.settimeout(self.connect_timeout) 2790s sock.connect(self.unix_socket) 2790s self.host_info = "Localhost via UNIX socket" 2790s self._secure = True 2790s if DEBUG: 2790s print("connected using unix_socket") 2790s else: 2790s kwargs = {} 2790s if self.bind_address is not None: 2790s kwargs["source_address"] = (self.bind_address, 0) 2790s while True: 2790s try: 2790s sock = socket.create_connection( 2790s (self.host, self.port), self.connect_timeout, **kwargs 2790s ) 2790s break 2790s except OSError as e: 2790s if e.errno == errno.EINTR: 2790s continue 2790s raise 2790s self.host_info = "socket %s:%d" % (self.host, self.port) 2790s if DEBUG: 2790s print("connected using socket") 2790s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2790s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2790s sock.settimeout(None) 2790s 2790s self._sock = sock 2790s self._rfile = sock.makefile("rb") 2790s self._next_seq_id = 0 2790s 2790s self._get_server_information() 2790s self._request_authentication() 2790s 2790s # Send "SET NAMES" query on init for: 2790s # - Ensure charaset (and collation) is set to the server. 2790s # - collation_id in handshake packet may be ignored. 2790s # - If collation is not specified, we don't know what is server's 2790s # default collation for the charset. For example, default collation 2790s # of utf8mb4 is: 2790s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2790s # - MySQL 8.0: utf8mb4_0900_ai_ci 2790s # 2790s # Reference: 2790s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2790s # - https://github.com/wagtail/wagtail/issues/9477 2790s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2790s self.set_character_set(self.charset, self.collation) 2790s 2790s if self.sql_mode is not None: 2790s c = self.cursor() 2790s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2790s c.close() 2790s 2790s if self.init_command is not None: 2790s c = self.cursor() 2790s c.execute(self.init_command) 2790s c.close() 2790s 2790s if self.autocommit_mode is not None: 2790s self.autocommit(self.autocommit_mode) 2790s except BaseException as e: 2790s self._rfile = None 2790s if sock is not None: 2790s try: 2790s sock.close() 2790s except: # noqa 2790s pass 2790s 2790s if isinstance(e, (OSError, IOError)): 2790s exc = err.OperationalError( 2790s CR.CR_CONN_HOST_ERROR, 2790s f"Can't connect to MySQL server on {self.host!r} ({e})", 2790s ) 2790s # Keep original exception and traceback to investigate error. 2790s exc.original_exception = e 2790s exc.traceback = traceback.format_exc() 2790s if DEBUG: 2790s print(exc.traceback) 2790s > raise exc 2790s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2790s _ test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_engine] _ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s request = > 2790s func = 'read_sql_query', dtype_backend = 'numpy_nullable' 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2790s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2790s def test_read_sql_dtype(conn, request, func, dtype_backend): 2790s # GH#50797 2790s conn = request.getfixturevalue(conn) 2790s table = "test" 2790s df = DataFrame({"a": [1, 2, 3], "b": 5}) 2790s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2790s return func(*args, **kwargs) 2790s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2790s return sql.to_sql( 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2790s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2790s return SQLDatabase(con, schema, need_transaction) 2790s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2790s con = self.exit_stack.enter_context(con.connect()) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _ test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_conn] __ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s conn = 'postgresql_psycopg2_conn' 2790s request = > 2790s func = 'read_sql_query', dtype_backend = 'numpy_nullable' 2790s 2790s @pytest.mark.parametrize("conn", all_connectable) 2790s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2790s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2790s def test_read_sql_dtype(conn, request, func, dtype_backend): 2790s # GH#50797 2790s > conn = request.getfixturevalue(conn) 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2790s fixturedef = self._get_active_fixturedef(argname) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2790s fixturedef.execute(request=subrequest) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2790s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2790s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2790s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2790s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2790s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2790s return (yield) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2790s result = call_fixture_func(fixturefunc, request, kwargs) 2790s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2790s fixture_result = next(generator) 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2790s with postgresql_psycopg2_engine.connect() as conn: 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _________________________ test_psycopg2_schema_support _________________________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s postgresql_psycopg2_engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s 2790s @pytest.mark.db 2790s def test_psycopg2_schema_support(postgresql_psycopg2_engine): 2790s conn = postgresql_psycopg2_engine 2790s 2790s # only test this for postgresql (schema's not supported in 2790s # mysql/sqlite) 2790s df = DataFrame({"col1": [1, 2], "col2": [0.1, 0.2], "col3": ["a", "n"]}) 2790s 2790s # create a schema 2790s > with conn.connect() as con: 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3905: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s _________________________ test_self_join_date_columns __________________________ 2790s self = 2790s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s connection = None, _has_events = None, _allow_revalidate = True 2790s _allow_autobegin = True 2790s 2790s def __init__( 2790s self, 2790s engine: Engine, 2790s connection: Optional[PoolProxiedConnection] = None, 2790s _has_events: Optional[bool] = None, 2790s _allow_revalidate: bool = True, 2790s _allow_autobegin: bool = True, 2790s ): 2790s """Construct a new Connection.""" 2790s self.engine = engine 2790s self.dialect = dialect = engine.dialect 2790s 2790s if connection is None: 2790s try: 2790s > self._dbapi_connection = engine.raw_connection() 2790s 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s 2790s The above exception was the direct cause of the following exception: 2790s 2790s postgresql_psycopg2_engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2790s 2790s @pytest.mark.db 2790s def test_self_join_date_columns(postgresql_psycopg2_engine): 2790s # GH 44421 2790s conn = postgresql_psycopg2_engine 2790s from sqlalchemy.sql import text 2790s 2790s create_table = text( 2790s """ 2790s CREATE TABLE person 2790s ( 2790s id serial constraint person_pkey primary key, 2790s created_dt timestamp with time zone 2790s ); 2790s 2790s INSERT INTO person 2790s VALUES (1, '2021-01-01T00:00:00Z'); 2790s """ 2790s ) 2790s > with conn.connect() as con: 2790s 2790s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3989: 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2790s return self._connection_cls(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2790s Connection._handle_dbapi_exception_noconnection( 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2790s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2790s self._dbapi_connection = engine.raw_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2790s return self.pool.connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2790s return _ConnectionFairy._checkout(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2790s fairy = _ConnectionRecord.checkout(pool) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2790s rec = pool._do_get() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2790s return self._create_connection() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2790s return _ConnectionRecord(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2790s self.__connect() 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2790s with util.safe_reraise(): 2790s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2790s raise exc_value.with_traceback(exc_tb) 2790s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2790s self.dbapi_connection = connection = pool._invoke_creator(self) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2790s return dialect.connect(*cargs, **cparams) 2790s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2790s return self.loaded_dbapi.connect(*cargs, **cparams) 2790s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2790s 2790s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2790s connection_factory = None, cursor_factory = None 2790s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2790s kwasync = {} 2790s 2790s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2790s """ 2790s Create a new database connection. 2790s 2790s The connection parameters can be specified as a string: 2790s 2790s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2790s 2790s or using a set of keyword arguments: 2790s 2790s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2790s 2790s Or as a mix of both. The basic connection parameters are: 2790s 2790s - *dbname*: the database name 2790s - *database*: the database name (only as keyword argument) 2790s - *user*: user name used to authenticate 2790s - *password*: password used to authenticate 2790s - *host*: database host address (defaults to UNIX socket if not provided) 2790s - *port*: connection port number (defaults to 5432 if not provided) 2790s 2790s Using the *connection_factory* parameter a different class or connections 2790s factory can be specified. It should be a callable object taking a dsn 2790s argument. 2790s 2790s Using the *cursor_factory* parameter, a new default cursor factory will be 2790s used by cursor(). 2790s 2790s Using *async*=True an asynchronous connection will be created. *async_* is 2790s a valid alias (for Python versions where ``async`` is a keyword). 2790s 2790s Any other keyword parameter will be passed to the underlying client 2790s library: the list of supported parameters depends on the library version. 2790s 2790s """ 2790s kwasync = {} 2790s if 'async' in kwargs: 2790s kwasync['async'] = kwargs.pop('async') 2790s if 'async_' in kwargs: 2790s kwasync['async_'] = kwargs.pop('async_') 2790s 2790s dsn = _ext.make_dsn(dsn, **kwargs) 2790s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2790s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2790s E Is the server running on that host and accepting TCP/IP connections? 2790s E 2790s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2790s 2790s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2790s =============================== warnings summary =============================== 2790s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:895 2790s /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 2790s pytest.param("mysql_pymysql_engine", marks=pytest.mark.db), 2790s 2790s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:896 2790s /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 2790s pytest.param("mysql_pymysql_conn", marks=pytest.mark.db), 2790s 2790s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:900 2790s /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 2790s pytest.param("mysql_pymysql_engine_iris", marks=pytest.mark.db), 2790s 2790s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:901 2790s /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 2790s pytest.param("mysql_pymysql_conn_iris", marks=pytest.mark.db), 2790s 2790s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:905 2790s /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 2790s pytest.param("mysql_pymysql_engine_types", marks=pytest.mark.db), 2790s 2790s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:906 2790s /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 2790s pytest.param("mysql_pymysql_conn_types", marks=pytest.mark.db), 2790s 2790s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:910 2790s /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 2790s pytest.param("postgresql_psycopg2_engine", marks=pytest.mark.db), 2790s 2790s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:911 2790s /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 2790s pytest.param("postgresql_psycopg2_conn", marks=pytest.mark.db), 2790s 2790s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:915 2790s /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 2790s pytest.param("postgresql_psycopg2_engine_iris", marks=pytest.mark.db), 2790s 2790s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:916 2790s /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 2790s pytest.param("postgresql_psycopg2_conn_iris", marks=pytest.mark.db), 2790s 2790s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:920 2790s /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 2790s pytest.param("postgresql_psycopg2_engine_types", marks=pytest.mark.db), 2790s 2790s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:921 2790s /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 2790s pytest.param("postgresql_psycopg2_conn_types", marks=pytest.mark.db), 2790s 2790s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:954 2790s /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 2790s pytest.param("postgresql_adbc_conn", marks=pytest.mark.db), 2790s 2790s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:958 2790s /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 2790s pytest.param("postgresql_adbc_iris", marks=pytest.mark.db), 2790s 2790s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:959 2790s /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 2790s pytest.param("sqlite_adbc_iris", marks=pytest.mark.db), 2790s 2790s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:963 2790s /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 2790s pytest.param("postgresql_adbc_types", marks=pytest.mark.db), 2790s 2790s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:964 2790s /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 2790s pytest.param("sqlite_adbc_types", marks=pytest.mark.db), 2790s 2790s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3896 2790s /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 2790s @pytest.mark.db 2790s 2790s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3971 2790s /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 2790s @pytest.mark.db 2790s 2790s ../../../usr/lib/python3/dist-packages/pandas/tests/tools/test_to_datetime.py:1143 2790s /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 2790s @pytest.mark.skip_ubsan 2790s 2790s io/test_sql.py: 1535 warnings 2790s tools/test_to_datetime.py: 978 warnings 2790s /usr/lib/python3/dist-packages/py/_process/forkedfunc.py:45: DeprecationWarning: This process (pid=17894) is multi-threaded, use of fork() may lead to deadlocks in the child. 2790s pid = os.fork() 2790s 2790s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 2790s /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-e44v4k_6' 2790s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 2790s 2790s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:429 2790s /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-mdtyw3b7' 2790s config.cache.set("cache/lastfailed", self.lastfailed) 2790s 2790s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 2790s /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-xn265swl' 2790s session.config.cache.set(STEPWISE_CACHE_DIR, []) 2790s 2790s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 2790s =========================== short test summary info ============================ 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[mysql_pymysql_engine_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[mysql_pymysql_conn_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[postgresql_psycopg2_engine_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[postgresql_psycopg2_conn_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[mysql_pymysql_engine_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[mysql_pymysql_conn_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[postgresql_psycopg2_engine_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[postgresql_psycopg2_conn_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[mysql_pymysql_engine_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[mysql_pymysql_conn_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[postgresql_psycopg2_engine_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[postgresql_psycopg2_conn_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[mysql_pymysql_engine_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[mysql_pymysql_conn_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[postgresql_psycopg2_engine_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[postgresql_psycopg2_conn_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[mysql_pymysql_engine_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[mysql_pymysql_conn_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[postgresql_psycopg2_engine_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[postgresql_psycopg2_conn_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[mysql_pymysql_engine_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[mysql_pymysql_conn_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[postgresql_psycopg2_engine_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[postgresql_psycopg2_conn_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[mysql_pymysql_engine_types] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[mysql_pymysql_conn_types] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[postgresql_psycopg2_engine_types] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[postgresql_psycopg2_conn_types] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_procedure[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_procedure[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[2-postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[2-postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_on_public_schema[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_on_public_schema[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_update[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_update[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_view_postgres[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_view_postgres[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[mysql_pymysql_engine_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[mysql_pymysql_conn_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[postgresql_psycopg2_engine_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[postgresql_psycopg2_conn_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[mysql_pymysql_engine_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[mysql_pymysql_conn_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[postgresql_psycopg2_engine_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[postgresql_psycopg2_conn_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[mysql_pymysql_engine_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[mysql_pymysql_conn_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[postgresql_psycopg2_engine_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[postgresql_psycopg2_conn_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[mysql_pymysql_engine_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[mysql_pymysql_conn_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_engine_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_conn_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[mysql_pymysql_engine_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[mysql_pymysql_conn_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[postgresql_psycopg2_engine_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[postgresql_psycopg2_conn_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[mysql_pymysql_engine_types] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[mysql_pymysql_conn_types] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[postgresql_psycopg2_engine_types] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[postgresql_psycopg2_conn_types] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[mysql_pymysql_engine_types] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[mysql_pymysql_conn_types] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[postgresql_psycopg2_engine_types] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[postgresql_psycopg2_conn_types] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_conn] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label_multiindex[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label_multiindex[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[mysql_pymysql_engine_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[mysql_pymysql_conn_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[postgresql_psycopg2_engine_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[postgresql_psycopg2_conn_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-INTEGER-mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-INTEGER-mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-INTEGER-postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-INTEGER-postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_database_uri_string[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_database_uri_string[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_pg8000_sqlalchemy_passthrough_error[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_pg8000_sqlalchemy_passthrough_error[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[mysql_pymysql_engine_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[mysql_pymysql_conn_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[postgresql_psycopg2_engine_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[postgresql_psycopg2_conn_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[mysql_pymysql_engine_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[mysql_pymysql_conn_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[postgresql_psycopg2_engine_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[postgresql_psycopg2_conn_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[mysql_pymysql_engine_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[mysql_pymysql_conn_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[postgresql_psycopg2_engine_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[postgresql_psycopg2_conn_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[mysql_pymysql_engine_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[mysql_pymysql_conn_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[postgresql_psycopg2_engine_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[postgresql_psycopg2_conn_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[mysql_pymysql_engine_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[mysql_pymysql_conn_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[postgresql_psycopg2_engine_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[postgresql_psycopg2_conn_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[mysql_pymysql_engine_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[mysql_pymysql_conn_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[postgresql_psycopg2_engine_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[postgresql_psycopg2_conn_iris] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_default_type_conversion[postgresql_psycopg2_engine_types] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_default_type_conversion[postgresql_psycopg2_conn_types] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[mysql_pymysql_engine_types] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[mysql_pymysql_conn_types] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[postgresql_psycopg2_engine_types] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[postgresql_psycopg2_conn_types] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[None-postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[None-postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_table[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_table[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[mysql_pymysql_engine_types] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[mysql_pymysql_conn_types] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[postgresql_psycopg2_engine_types] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[postgresql_psycopg2_conn_types] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[postgresql_psycopg2_conn] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_conn] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_conn] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_engine] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_conn] 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_psycopg2_schema_support 2790s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_self_join_date_columns 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[mysql_pymysql_engine_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[mysql_pymysql_conn_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[postgresql_psycopg2_engine_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[postgresql_psycopg2_conn_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[mysql_pymysql_engine_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[mysql_pymysql_conn_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[postgresql_psycopg2_engine_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[postgresql_psycopg2_conn_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[mysql_pymysql_engine_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[mysql_pymysql_conn_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[postgresql_psycopg2_engine_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[postgresql_psycopg2_conn_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[mysql_pymysql_engine_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[mysql_pymysql_conn_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[postgresql_psycopg2_engine_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[postgresql_psycopg2_conn_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[mysql_pymysql_engine_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[mysql_pymysql_conn_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[postgresql_psycopg2_engine_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[postgresql_psycopg2_conn_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[mysql_pymysql_engine_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[mysql_pymysql_conn_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[postgresql_psycopg2_engine_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[postgresql_psycopg2_conn_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[mysql_pymysql_engine_types] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[mysql_pymysql_conn_types] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[postgresql_psycopg2_engine_types] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[postgresql_psycopg2_conn_types] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_procedure[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_procedure[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[2-postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[2-postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_on_public_schema[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_on_public_schema[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_update[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_update[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_view_postgres[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_view_postgres[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[mysql_pymysql_engine_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[mysql_pymysql_conn_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[postgresql_psycopg2_engine_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[postgresql_psycopg2_conn_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[mysql_pymysql_engine_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[mysql_pymysql_conn_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[postgresql_psycopg2_engine_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[postgresql_psycopg2_conn_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[mysql_pymysql_engine_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[mysql_pymysql_conn_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[postgresql_psycopg2_engine_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[postgresql_psycopg2_conn_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[mysql_pymysql_engine_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[mysql_pymysql_conn_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_engine_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_conn_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[mysql_pymysql_engine_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[mysql_pymysql_conn_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[postgresql_psycopg2_engine_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[postgresql_psycopg2_conn_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[mysql_pymysql_engine_types] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[mysql_pymysql_conn_types] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[postgresql_psycopg2_engine_types] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[postgresql_psycopg2_conn_types] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[mysql_pymysql_engine_types] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[mysql_pymysql_conn_types] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[postgresql_psycopg2_engine_types] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[postgresql_psycopg2_conn_types] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_conn] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label_multiindex[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label_multiindex[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[mysql_pymysql_engine_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[mysql_pymysql_conn_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[postgresql_psycopg2_engine_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[postgresql_psycopg2_conn_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-INTEGER-mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-INTEGER-mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-INTEGER-postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-INTEGER-postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_database_uri_string[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_database_uri_string[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_database_uri_string[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_database_uri_string[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_pg8000_sqlalchemy_passthrough_error[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_pg8000_sqlalchemy_passthrough_error[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_pg8000_sqlalchemy_passthrough_error[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_pg8000_sqlalchemy_passthrough_error[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[mysql_pymysql_engine_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[mysql_pymysql_conn_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[postgresql_psycopg2_engine_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[postgresql_psycopg2_conn_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[mysql_pymysql_engine_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[mysql_pymysql_conn_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[postgresql_psycopg2_engine_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[postgresql_psycopg2_conn_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[mysql_pymysql_engine_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[mysql_pymysql_conn_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[postgresql_psycopg2_engine_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[postgresql_psycopg2_conn_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[mysql_pymysql_engine_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[mysql_pymysql_conn_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[postgresql_psycopg2_engine_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[postgresql_psycopg2_conn_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[mysql_pymysql_engine_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[mysql_pymysql_conn_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[postgresql_psycopg2_engine_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[postgresql_psycopg2_conn_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[mysql_pymysql_engine_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[mysql_pymysql_conn_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[postgresql_psycopg2_engine_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[postgresql_psycopg2_conn_iris] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_default_type_conversion[postgresql_psycopg2_engine_types] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_default_type_conversion[postgresql_psycopg2_conn_types] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[mysql_pymysql_engine_types] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[mysql_pymysql_conn_types] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[postgresql_psycopg2_engine_types] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[postgresql_psycopg2_conn_types] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[None-postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[None-postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_table[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_table[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[mysql_pymysql_engine_types] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[mysql_pymysql_conn_types] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[postgresql_psycopg2_engine_types] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[postgresql_psycopg2_conn_types] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[postgresql_psycopg2_conn] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_conn] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_conn] 2790s 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] 2790s 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] 2790s 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] 2790s 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] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_engine] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_conn] 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_psycopg2_schema_support 2790s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_self_join_date_columns 2790s = 588 failed, 1481 passed, 400 skipped, 54 xfailed, 2536 warnings, 592 errors in 772.30s (0:12:52) = 2790s autopkgtest [18:10:09]: test ignoredtests: -----------------------] 2795s autopkgtest [18:10:14]: test ignoredtests: - - - - - - - - - - results - - - - - - - - - - 2795s ignoredtests PASS 2798s autopkgtest [18:10:17]: @@@@@@@@@@@@@@@@@@@@ summary 2798s command1 PASS 2798s unittests3 PASS 2798s ignoredtests PASS